| OLD | NEW |
| 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 library analyzer.src.generated.ast; | 5 library analyzer.src.generated.ast; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 11 import 'package:analyzer/dart/element/type.dart'; |
| 11 import 'package:analyzer/src/dart/ast/utilities.dart'; | 12 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 12 import 'package:analyzer/src/dart/element/element.dart'; | 13 import 'package:analyzer/src/dart/element/element.dart'; |
| 13 import 'package:analyzer/src/dart/element/type.dart'; | 14 import 'package:analyzer/src/dart/element/type.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; | 15 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine; |
| 15 import 'package:analyzer/src/generated/java_core.dart'; | 16 import 'package:analyzer/src/generated/java_core.dart'; |
| 16 import 'package:analyzer/src/generated/java_engine.dart'; | 17 import 'package:analyzer/src/generated/java_engine.dart'; |
| 17 import 'package:analyzer/src/generated/parser.dart'; | 18 import 'package:analyzer/src/generated/parser.dart'; |
| 18 import 'package:analyzer/src/generated/scanner.dart'; | 19 import 'package:analyzer/src/generated/scanner.dart'; |
| 19 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; | 20 import 'package:analyzer/src/generated/source.dart' show LineInfo, Source; |
| 20 import 'package:analyzer/src/generated/utilities_dart.dart'; | 21 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 21 | 22 |
| 23 export 'package:analyzer/dart/ast/ast.dart'; |
| 22 export 'package:analyzer/dart/ast/visitor.dart'; | 24 export 'package:analyzer/dart/ast/visitor.dart'; |
| 23 export 'package:analyzer/src/dart/ast/utilities.dart'; | 25 export 'package:analyzer/src/dart/ast/utilities.dart'; |
| 24 | 26 |
| 25 /** | 27 /** |
| 26 * Two or more string literals that are implicitly concatenated because of being | 28 * Two or more string literals that are implicitly concatenated because of being |
| 27 * adjacent (separated only by whitespace). | 29 * adjacent (separated only by whitespace). |
| 28 * | 30 * |
| 29 * While the grammar only allows adjacent strings when all of the strings are of | 31 * While the grammar only allows adjacent strings when all of the strings are of |
| 30 * the same kind (single line or multi-line), this class doesn't enforce that | 32 * the same kind (single line or multi-line), this class doesn't enforce that |
| 31 * restriction. | 33 * restriction. |
| 32 * | 34 * |
| 33 * > adjacentStrings ::= | 35 * > adjacentStrings ::= |
| 34 * > [StringLiteral] [StringLiteral]+ | 36 * > [StringLiteral] [StringLiteral]+ |
| 35 */ | 37 */ |
| 36 class AdjacentStrings extends StringLiteral { | 38 class AdjacentStringsImpl extends StringLiteralImpl implements AdjacentStrings { |
| 37 /** | 39 /** |
| 38 * The strings that are implicitly concatenated. | 40 * The strings that are implicitly concatenated. |
| 39 */ | 41 */ |
| 40 NodeList<StringLiteral> _strings; | 42 NodeList<StringLiteral> _strings; |
| 41 | 43 |
| 42 /** | 44 /** |
| 43 * Initialize a newly created list of adjacent strings. To be syntactically | 45 * Initialize a newly created list of adjacent strings. To be syntactically |
| 44 * valid, the list of [strings] must contain at least two elements. | 46 * valid, the list of [strings] must contain at least two elements. |
| 45 */ | 47 */ |
| 46 AdjacentStrings(List<StringLiteral> strings) { | 48 AdjacentStringsImpl(List<StringLiteral> strings) { |
| 47 _strings = new NodeList<StringLiteral>(this, strings); | 49 _strings = new NodeList<StringLiteral>(this, strings); |
| 48 } | 50 } |
| 49 | 51 |
| 50 @override | 52 @override |
| 51 Token get beginToken => _strings.beginToken; | 53 Token get beginToken => _strings.beginToken; |
| 52 | 54 |
| 53 @override | 55 @override |
| 54 Iterable get childEntities => new ChildEntities()..addAll(_strings); | 56 Iterable get childEntities => new ChildEntities()..addAll(_strings); |
| 55 | 57 |
| 56 @override | 58 @override |
| 57 Token get endToken => _strings.endToken; | 59 Token get endToken => _strings.endToken; |
| 58 | 60 |
| 59 /** | 61 @override |
| 60 * Return the strings that are implicitly concatenated. | |
| 61 */ | |
| 62 NodeList<StringLiteral> get strings => _strings; | 62 NodeList<StringLiteral> get strings => _strings; |
| 63 | 63 |
| 64 @override | 64 @override |
| 65 accept(AstVisitor visitor) => visitor.visitAdjacentStrings(this); | 65 accept(AstVisitor visitor) => visitor.visitAdjacentStrings(this); |
| 66 | 66 |
| 67 @override | 67 @override |
| 68 void visitChildren(AstVisitor visitor) { | 68 void visitChildren(AstVisitor visitor) { |
| 69 _strings.accept(visitor); | 69 _strings.accept(visitor); |
| 70 } | 70 } |
| 71 | 71 |
| 72 @override | 72 @override |
| 73 void _appendStringValue(StringBuffer buffer) { | 73 void _appendStringValue(StringBuffer buffer) { |
| 74 for (StringLiteral stringLiteral in strings) { | 74 for (StringLiteralImpl stringLiteral in strings) { |
| 75 stringLiteral._appendStringValue(buffer); | 75 stringLiteral._appendStringValue(buffer); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * An AST node that can be annotated with both a documentation comment and a | 81 * An AST node that can be annotated with both a documentation comment and a |
| 82 * list of annotations. | 82 * list of annotations. |
| 83 */ | 83 */ |
| 84 abstract class AnnotatedNode extends AstNode { | 84 abstract class AnnotatedNodeImpl extends AstNodeImpl implements AnnotatedNode { |
| 85 /** | 85 /** |
| 86 * The documentation comment associated with this node, or `null` if this node | 86 * The documentation comment associated with this node, or `null` if this node |
| 87 * does not have a documentation comment associated with it. | 87 * does not have a documentation comment associated with it. |
| 88 */ | 88 */ |
| 89 Comment _comment; | 89 Comment _comment; |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * The annotations associated with this node. | 92 * The annotations associated with this node. |
| 93 */ | 93 */ |
| 94 NodeList<Annotation> _metadata; | 94 NodeList<Annotation> _metadata; |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * Initialize a newly created annotated node. Either or both of the [comment] | 97 * Initialize a newly created annotated node. Either or both of the [comment] |
| 98 * and [metadata] can be `null` if the node does not have the corresponding | 98 * and [metadata] can be `null` if the node does not have the corresponding |
| 99 * attribute. | 99 * attribute. |
| 100 */ | 100 */ |
| 101 AnnotatedNode(Comment comment, List<Annotation> metadata) { | 101 AnnotatedNodeImpl(Comment comment, List<Annotation> metadata) { |
| 102 _comment = _becomeParentOf(comment); | 102 _comment = _becomeParentOf(comment); |
| 103 _metadata = new NodeList<Annotation>(this, metadata); | 103 _metadata = new NodeList<Annotation>(this, metadata); |
| 104 } | 104 } |
| 105 | 105 |
| 106 @override | 106 @override |
| 107 Token get beginToken { | 107 Token get beginToken { |
| 108 if (_comment == null) { | 108 if (_comment == null) { |
| 109 if (_metadata.isEmpty) { | 109 if (_metadata.isEmpty) { |
| 110 return firstTokenAfterCommentAndMetadata; | 110 return firstTokenAfterCommentAndMetadata; |
| 111 } | 111 } |
| 112 return _metadata.beginToken; | 112 return _metadata.beginToken; |
| 113 } else if (_metadata.isEmpty) { | 113 } else if (_metadata.isEmpty) { |
| 114 return _comment.beginToken; | 114 return _comment.beginToken; |
| 115 } | 115 } |
| 116 Token commentToken = _comment.beginToken; | 116 Token commentToken = _comment.beginToken; |
| 117 Token metadataToken = _metadata.beginToken; | 117 Token metadataToken = _metadata.beginToken; |
| 118 if (commentToken.offset < metadataToken.offset) { | 118 if (commentToken.offset < metadataToken.offset) { |
| 119 return commentToken; | 119 return commentToken; |
| 120 } | 120 } |
| 121 return metadataToken; | 121 return metadataToken; |
| 122 } | 122 } |
| 123 | 123 |
| 124 /** | 124 @override |
| 125 * Return the documentation comment associated with this node, or `null` if | |
| 126 * this node does not have a documentation comment associated with it. | |
| 127 */ | |
| 128 Comment get documentationComment => _comment; | 125 Comment get documentationComment => _comment; |
| 129 | 126 |
| 130 /** | 127 @override |
| 131 * Set the documentation comment associated with this node to the given | |
| 132 * [comment]. | |
| 133 */ | |
| 134 void set documentationComment(Comment comment) { | 128 void set documentationComment(Comment comment) { |
| 135 _comment = _becomeParentOf(comment); | 129 _comment = _becomeParentOf(comment); |
| 136 } | 130 } |
| 137 | 131 |
| 138 /** | 132 @override |
| 139 * Return the first token following the comment and metadata. | |
| 140 */ | |
| 141 Token get firstTokenAfterCommentAndMetadata; | |
| 142 | |
| 143 /** | |
| 144 * Return the annotations associated with this node. | |
| 145 */ | |
| 146 NodeList<Annotation> get metadata => _metadata; | 133 NodeList<Annotation> get metadata => _metadata; |
| 147 | 134 |
| 148 /** | 135 @override |
| 149 * Return a list containing the comment and annotations associated with this | |
| 150 * node, sorted in lexical order. | |
| 151 */ | |
| 152 List<AstNode> get sortedCommentAndAnnotations { | 136 List<AstNode> get sortedCommentAndAnnotations { |
| 153 return <AstNode>[] | 137 return <AstNode>[] |
| 154 ..add(_comment) | 138 ..add(_comment) |
| 155 ..addAll(_metadata) | 139 ..addAll(_metadata) |
| 156 ..sort(AstNode.LEXICAL_ORDER); | 140 ..sort(AstNode.LEXICAL_ORDER); |
| 157 } | 141 } |
| 158 | 142 |
| 159 /** | 143 /** |
| 160 * Return a holder of child entities that subclasses can add to. | 144 * Return a holder of child entities that subclasses can add to. |
| 161 */ | 145 */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 182 } | 166 } |
| 183 } | 167 } |
| 184 } | 168 } |
| 185 | 169 |
| 186 /** | 170 /** |
| 187 * Return `true` if there are no annotations before the comment. Note that a | 171 * Return `true` if there are no annotations before the comment. Note that a |
| 188 * result of `true` does not imply that there is a comment, nor that there are | 172 * result of `true` does not imply that there is a comment, nor that there are |
| 189 * annotations associated with this node. | 173 * annotations associated with this node. |
| 190 */ | 174 */ |
| 191 bool _commentIsBeforeAnnotations() { | 175 bool _commentIsBeforeAnnotations() { |
| 192 // TODO(brianwilkerson) Convert this to a getter. | |
| 193 if (_comment == null || _metadata.isEmpty) { | 176 if (_comment == null || _metadata.isEmpty) { |
| 194 return true; | 177 return true; |
| 195 } | 178 } |
| 196 Annotation firstAnnotation = _metadata[0]; | 179 Annotation firstAnnotation = _metadata[0]; |
| 197 return _comment.offset < firstAnnotation.offset; | 180 return _comment.offset < firstAnnotation.offset; |
| 198 } | 181 } |
| 199 } | 182 } |
| 200 | 183 |
| 201 /** | 184 /** |
| 202 * An annotation that can be associated with an AST node. | 185 * An annotation that can be associated with an AST node. |
| 203 * | 186 * |
| 204 * > metadata ::= | 187 * > metadata ::= |
| 205 * > annotation* | 188 * > annotation* |
| 206 * > | 189 * > |
| 207 * > annotation ::= | 190 * > annotation ::= |
| 208 * > '@' [Identifier] ('.' [SimpleIdentifier])? [ArgumentList]? | 191 * > '@' [Identifier] ('.' [SimpleIdentifier])? [ArgumentList]? |
| 209 */ | 192 */ |
| 210 class Annotation extends AstNode { | 193 class AnnotationImpl extends AstNodeImpl implements Annotation { |
| 211 /** | 194 /** |
| 212 * The at sign that introduced the annotation. | 195 * The at sign that introduced the annotation. |
| 213 */ | 196 */ |
| 214 Token atSign; | 197 Token atSign; |
| 215 | 198 |
| 216 /** | 199 /** |
| 217 * The name of the class defining the constructor that is being invoked or the | 200 * The name of the class defining the constructor that is being invoked or the |
| 218 * name of the field that is being referenced. | 201 * name of the field that is being referenced. |
| 219 */ | 202 */ |
| 220 Identifier _name; | 203 Identifier _name; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 247 * The element annotation representing this annotation in the element model. | 230 * The element annotation representing this annotation in the element model. |
| 248 */ | 231 */ |
| 249 ElementAnnotation elementAnnotation; | 232 ElementAnnotation elementAnnotation; |
| 250 | 233 |
| 251 /** | 234 /** |
| 252 * Initialize a newly created annotation. Both the [period] and the | 235 * Initialize a newly created annotation. Both the [period] and the |
| 253 * [constructorName] can be `null` if the annotation is not referencing a | 236 * [constructorName] can be `null` if the annotation is not referencing a |
| 254 * named constructor. The [arguments] can be `null` if the annotation is not | 237 * named constructor. The [arguments] can be `null` if the annotation is not |
| 255 * referencing a constructor. | 238 * referencing a constructor. |
| 256 */ | 239 */ |
| 257 Annotation(this.atSign, Identifier name, this.period, | 240 AnnotationImpl(this.atSign, Identifier name, this.period, |
| 258 SimpleIdentifier constructorName, ArgumentList arguments) { | 241 SimpleIdentifier constructorName, ArgumentList arguments) { |
| 259 _name = _becomeParentOf(name); | 242 _name = _becomeParentOf(name); |
| 260 _constructorName = _becomeParentOf(constructorName); | 243 _constructorName = _becomeParentOf(constructorName); |
| 261 _arguments = _becomeParentOf(arguments); | 244 _arguments = _becomeParentOf(arguments); |
| 262 } | 245 } |
| 263 | 246 |
| 264 /** | 247 @override |
| 265 * Return the arguments to the constructor being invoked, or `null` if this | |
| 266 * annotation is not the invocation of a constructor. | |
| 267 */ | |
| 268 ArgumentList get arguments => _arguments; | 248 ArgumentList get arguments => _arguments; |
| 269 | 249 |
| 270 /** | 250 @override |
| 271 * Set the arguments to the constructor being invoked to the given arguments. | |
| 272 */ | |
| 273 void set arguments(ArgumentList arguments) { | 251 void set arguments(ArgumentList arguments) { |
| 274 _arguments = _becomeParentOf(arguments); | 252 _arguments = _becomeParentOf(arguments); |
| 275 } | 253 } |
| 276 | 254 |
| 277 @override | 255 @override |
| 278 Token get beginToken => atSign; | 256 Token get beginToken => atSign; |
| 279 | 257 |
| 280 @override | 258 @override |
| 281 Iterable get childEntities => new ChildEntities() | 259 Iterable get childEntities => new ChildEntities() |
| 282 ..add(atSign) | 260 ..add(atSign) |
| 283 ..add(_name) | 261 ..add(_name) |
| 284 ..add(period) | 262 ..add(period) |
| 285 ..add(_constructorName) | 263 ..add(_constructorName) |
| 286 ..add(_arguments); | 264 ..add(_arguments); |
| 287 | 265 |
| 288 /** | 266 @override |
| 289 * Return the name of the constructor being invoked, or `null` if this | |
| 290 * annotation is not the invocation of a named constructor. | |
| 291 */ | |
| 292 SimpleIdentifier get constructorName => _constructorName; | 267 SimpleIdentifier get constructorName => _constructorName; |
| 293 | 268 |
| 294 /** | 269 @override |
| 295 * Set the name of the constructor being invoked to the given [name]. | |
| 296 */ | |
| 297 void set constructorName(SimpleIdentifier name) { | 270 void set constructorName(SimpleIdentifier name) { |
| 298 _constructorName = _becomeParentOf(name); | 271 _constructorName = _becomeParentOf(name); |
| 299 } | 272 } |
| 300 | 273 |
| 301 /** | 274 @override |
| 302 * Return the element associated with this annotation, or `null` if the AST | |
| 303 * structure has not been resolved or if this annotation could not be | |
| 304 * resolved. | |
| 305 */ | |
| 306 Element get element { | 275 Element get element { |
| 307 if (_element != null) { | 276 if (_element != null) { |
| 308 return _element; | 277 return _element; |
| 309 } else if (_name != null) { | 278 } else if (_name != null) { |
| 310 return _name.staticElement; | 279 return _name.staticElement; |
| 311 } | 280 } |
| 312 return null; | 281 return null; |
| 313 } | 282 } |
| 314 | 283 |
| 315 /** | 284 @override |
| 316 * Set the element associated with this annotation to the given [element]. | |
| 317 */ | |
| 318 void set element(Element element) { | 285 void set element(Element element) { |
| 319 _element = element; | 286 _element = element; |
| 320 } | 287 } |
| 321 | 288 |
| 322 @override | 289 @override |
| 323 Token get endToken { | 290 Token get endToken { |
| 324 if (_arguments != null) { | 291 if (_arguments != null) { |
| 325 return _arguments.endToken; | 292 return _arguments.endToken; |
| 326 } else if (_constructorName != null) { | 293 } else if (_constructorName != null) { |
| 327 return _constructorName.endToken; | 294 return _constructorName.endToken; |
| 328 } | 295 } |
| 329 return _name.endToken; | 296 return _name.endToken; |
| 330 } | 297 } |
| 331 | 298 |
| 332 /** | 299 @override |
| 333 * Return the name of the class defining the constructor that is being invoked | |
| 334 * or the name of the field that is being referenced. | |
| 335 */ | |
| 336 Identifier get name => _name; | 300 Identifier get name => _name; |
| 337 | 301 |
| 338 /** | 302 @override |
| 339 * Set the name of the class defining the constructor that is being invoked or | |
| 340 * the name of the field that is being referenced to the given [name]. | |
| 341 */ | |
| 342 void set name(Identifier name) { | 303 void set name(Identifier name) { |
| 343 _name = _becomeParentOf(name); | 304 _name = _becomeParentOf(name); |
| 344 } | 305 } |
| 345 | 306 |
| 346 @override | 307 @override |
| 347 accept(AstVisitor visitor) => visitor.visitAnnotation(this); | 308 accept(AstVisitor visitor) => visitor.visitAnnotation(this); |
| 348 | 309 |
| 349 @override | 310 @override |
| 350 void visitChildren(AstVisitor visitor) { | 311 void visitChildren(AstVisitor visitor) { |
| 351 _safelyVisitChild(_name, visitor); | 312 _safelyVisitChild(_name, visitor); |
| 352 _safelyVisitChild(_constructorName, visitor); | 313 _safelyVisitChild(_constructorName, visitor); |
| 353 _safelyVisitChild(_arguments, visitor); | 314 _safelyVisitChild(_arguments, visitor); |
| 354 } | 315 } |
| 355 } | 316 } |
| 356 | 317 |
| 357 /** | 318 /** |
| 358 * A list of arguments in the invocation of an executable element (that is, a | 319 * A list of arguments in the invocation of an executable element (that is, a |
| 359 * function, method, or constructor). | 320 * function, method, or constructor). |
| 360 * | 321 * |
| 361 * > argumentList ::= | 322 * > argumentList ::= |
| 362 * > '(' arguments? ')' | 323 * > '(' arguments? ')' |
| 363 * > | 324 * > |
| 364 * > arguments ::= | 325 * > arguments ::= |
| 365 * > [NamedExpression] (',' [NamedExpression])* | 326 * > [NamedExpression] (',' [NamedExpression])* |
| 366 * > | [Expression] (',' [Expression])* (',' [NamedExpression])* | 327 * > | [Expression] (',' [Expression])* (',' [NamedExpression])* |
| 367 */ | 328 */ |
| 368 class ArgumentList extends AstNode { | 329 class ArgumentListImpl extends AstNodeImpl implements ArgumentList { |
| 369 /** | 330 /** |
| 370 * The left parenthesis. | 331 * The left parenthesis. |
| 371 */ | 332 */ |
| 372 Token leftParenthesis; | 333 Token leftParenthesis; |
| 373 | 334 |
| 374 /** | 335 /** |
| 375 * The expressions producing the values of the arguments. | 336 * The expressions producing the values of the arguments. |
| 376 */ | 337 */ |
| 377 NodeList<Expression> _arguments; | 338 NodeList<Expression> _arguments; |
| 378 | 339 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 398 * based on propagated type information. The list must be the same length as | 359 * based on propagated type information. The list must be the same length as |
| 399 * the number of arguments, but can contain `null` entries if a given argument | 360 * the number of arguments, but can contain `null` entries if a given argument |
| 400 * does not correspond to a formal parameter. | 361 * does not correspond to a formal parameter. |
| 401 */ | 362 */ |
| 402 List<ParameterElement> _correspondingPropagatedParameters; | 363 List<ParameterElement> _correspondingPropagatedParameters; |
| 403 | 364 |
| 404 /** | 365 /** |
| 405 * Initialize a newly created list of arguments. The list of [arguments] can | 366 * Initialize a newly created list of arguments. The list of [arguments] can |
| 406 * be `null` if there are no arguments. | 367 * be `null` if there are no arguments. |
| 407 */ | 368 */ |
| 408 ArgumentList( | 369 ArgumentListImpl( |
| 409 this.leftParenthesis, List<Expression> arguments, this.rightParenthesis) { | 370 this.leftParenthesis, List<Expression> arguments, this.rightParenthesis) { |
| 410 _arguments = new NodeList<Expression>(this, arguments); | 371 _arguments = new NodeList<Expression>(this, arguments); |
| 411 } | 372 } |
| 412 | 373 |
| 413 /** | 374 @override |
| 414 * Return the expressions producing the values of the arguments. Although the | |
| 415 * language requires that positional arguments appear before named arguments, | |
| 416 * this class allows them to be intermixed. | |
| 417 */ | |
| 418 NodeList<Expression> get arguments => _arguments; | 375 NodeList<Expression> get arguments => _arguments; |
| 419 | 376 |
| 420 @override | 377 @override |
| 421 Token get beginToken => leftParenthesis; | 378 Token get beginToken => leftParenthesis; |
| 422 | 379 |
| 423 @override | 380 @override |
| 424 // TODO(paulberry): Add commas. | 381 // TODO(paulberry): Add commas. |
| 425 Iterable get childEntities => new ChildEntities() | 382 Iterable get childEntities => new ChildEntities() |
| 426 ..add(leftParenthesis) | 383 ..add(leftParenthesis) |
| 427 ..addAll(_arguments) | 384 ..addAll(_arguments) |
| 428 ..add(rightParenthesis); | 385 ..add(rightParenthesis); |
| 429 | 386 |
| 430 /** | 387 @override |
| 431 * Set the parameter elements corresponding to each of the arguments in this | |
| 432 * list to the given list of [parameters]. The list of parameters must be the | |
| 433 * same length as the number of arguments, but can contain `null` entries if a | |
| 434 * given argument does not correspond to a formal parameter. | |
| 435 */ | |
| 436 void set correspondingPropagatedParameters( | 388 void set correspondingPropagatedParameters( |
| 437 List<ParameterElement> parameters) { | 389 List<ParameterElement> parameters) { |
| 438 if (parameters.length != _arguments.length) { | 390 if (parameters.length != _arguments.length) { |
| 439 throw new IllegalArgumentException( | 391 throw new IllegalArgumentException( |
| 440 "Expected ${_arguments.length} parameters, not ${parameters.length}"); | 392 "Expected ${_arguments.length} parameters, not ${parameters.length}"); |
| 441 } | 393 } |
| 442 _correspondingPropagatedParameters = parameters; | 394 _correspondingPropagatedParameters = parameters; |
| 443 } | 395 } |
| 444 | 396 |
| 445 /** | 397 @override |
| 446 * Set the parameter elements corresponding to each of the arguments in this | |
| 447 * list to the given list of parameters. The list of parameters must be the | |
| 448 * same length as the number of arguments, but can contain `null` entries if a | |
| 449 * given argument does not correspond to a formal parameter. | |
| 450 */ | |
| 451 void set correspondingStaticParameters(List<ParameterElement> parameters) { | 398 void set correspondingStaticParameters(List<ParameterElement> parameters) { |
| 452 if (parameters.length != _arguments.length) { | 399 if (parameters.length != _arguments.length) { |
| 453 throw new IllegalArgumentException( | 400 throw new IllegalArgumentException( |
| 454 "Expected ${_arguments.length} parameters, not ${parameters.length}"); | 401 "Expected ${_arguments.length} parameters, not ${parameters.length}"); |
| 455 } | 402 } |
| 456 _correspondingStaticParameters = parameters; | 403 _correspondingStaticParameters = parameters; |
| 457 } | 404 } |
| 458 | 405 |
| 459 @override | 406 @override |
| 460 Token get endToken => rightParenthesis; | 407 Token get endToken => rightParenthesis; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return _correspondingStaticParameters[index]; | 467 return _correspondingStaticParameters[index]; |
| 521 } | 468 } |
| 522 } | 469 } |
| 523 | 470 |
| 524 /** | 471 /** |
| 525 * An as expression. | 472 * An as expression. |
| 526 * | 473 * |
| 527 * > asExpression ::= | 474 * > asExpression ::= |
| 528 * > [Expression] 'as' [TypeName] | 475 * > [Expression] 'as' [TypeName] |
| 529 */ | 476 */ |
| 530 class AsExpression extends Expression { | 477 class AsExpressionImpl extends ExpressionImpl implements AsExpression { |
| 531 /** | 478 /** |
| 532 * The expression used to compute the value being cast. | 479 * The expression used to compute the value being cast. |
| 533 */ | 480 */ |
| 534 Expression _expression; | 481 Expression _expression; |
| 535 | 482 |
| 536 /** | 483 /** |
| 537 * The 'as' operator. | 484 * The 'as' operator. |
| 538 */ | 485 */ |
| 539 Token asOperator; | 486 Token asOperator; |
| 540 | 487 |
| 541 /** | 488 /** |
| 542 * The name of the type being cast to. | 489 * The name of the type being cast to. |
| 543 */ | 490 */ |
| 544 TypeName _type; | 491 TypeName _type; |
| 545 | 492 |
| 546 /** | 493 /** |
| 547 * Initialize a newly created as expression. | 494 * Initialize a newly created as expression. |
| 548 */ | 495 */ |
| 549 AsExpression(Expression expression, this.asOperator, TypeName type) { | 496 AsExpressionImpl(Expression expression, this.asOperator, TypeName type) { |
| 550 _expression = _becomeParentOf(expression); | 497 _expression = _becomeParentOf(expression); |
| 551 _type = _becomeParentOf(type); | 498 _type = _becomeParentOf(type); |
| 552 } | 499 } |
| 553 | 500 |
| 554 @override | 501 @override |
| 555 Token get beginToken => _expression.beginToken; | 502 Token get beginToken => _expression.beginToken; |
| 556 | 503 |
| 557 @override | 504 @override |
| 558 Iterable get childEntities => | 505 Iterable get childEntities => |
| 559 new ChildEntities()..add(_expression)..add(asOperator)..add(_type); | 506 new ChildEntities()..add(_expression)..add(asOperator)..add(_type); |
| 560 | 507 |
| 561 @override | 508 @override |
| 562 Token get endToken => _type.endToken; | 509 Token get endToken => _type.endToken; |
| 563 | 510 |
| 564 /** | 511 @override |
| 565 * Return the expression used to compute the value being cast. | |
| 566 */ | |
| 567 Expression get expression => _expression; | 512 Expression get expression => _expression; |
| 568 | 513 |
| 569 /** | 514 @override |
| 570 * Set the expression used to compute the value being cast to the given | |
| 571 * [expression]. | |
| 572 */ | |
| 573 void set expression(Expression expression) { | 515 void set expression(Expression expression) { |
| 574 _expression = _becomeParentOf(expression); | 516 _expression = _becomeParentOf(expression); |
| 575 } | 517 } |
| 576 | 518 |
| 577 @override | 519 @override |
| 578 int get precedence => 7; | 520 int get precedence => 7; |
| 579 | 521 |
| 580 /** | 522 @override |
| 581 * Return the name of the type being cast to. | |
| 582 */ | |
| 583 TypeName get type => _type; | 523 TypeName get type => _type; |
| 584 | 524 |
| 585 /** | 525 @override |
| 586 * Set the name of the type being cast to to the given [name]. | |
| 587 */ | |
| 588 void set type(TypeName name) { | 526 void set type(TypeName name) { |
| 589 _type = _becomeParentOf(name); | 527 _type = _becomeParentOf(name); |
| 590 } | 528 } |
| 591 | 529 |
| 592 @override | 530 @override |
| 593 accept(AstVisitor visitor) => visitor.visitAsExpression(this); | 531 accept(AstVisitor visitor) => visitor.visitAsExpression(this); |
| 594 | 532 |
| 595 @override | 533 @override |
| 596 void visitChildren(AstVisitor visitor) { | 534 void visitChildren(AstVisitor visitor) { |
| 597 _safelyVisitChild(_expression, visitor); | 535 _safelyVisitChild(_expression, visitor); |
| 598 _safelyVisitChild(_type, visitor); | 536 _safelyVisitChild(_type, visitor); |
| 599 } | 537 } |
| 600 } | 538 } |
| 601 | 539 |
| 602 /** | 540 /** |
| 603 * An assert statement. | 541 * An assert statement. |
| 604 * | 542 * |
| 605 * > assertStatement ::= | 543 * > assertStatement ::= |
| 606 * > 'assert' '(' [Expression] ')' ';' | 544 * > 'assert' '(' [Expression] ')' ';' |
| 607 */ | 545 */ |
| 608 class AssertStatement extends Statement { | 546 class AssertStatementImpl extends StatementImpl implements AssertStatement { |
| 609 /** | 547 /** |
| 610 * The token representing the 'assert' keyword. | 548 * The token representing the 'assert' keyword. |
| 611 */ | 549 */ |
| 612 Token assertKeyword; | 550 Token assertKeyword; |
| 613 | 551 |
| 614 /** | 552 /** |
| 615 * The left parenthesis. | 553 * The left parenthesis. |
| 616 */ | 554 */ |
| 617 Token leftParenthesis; | 555 Token leftParenthesis; |
| 618 | 556 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 638 Token rightParenthesis; | 576 Token rightParenthesis; |
| 639 | 577 |
| 640 /** | 578 /** |
| 641 * The semicolon terminating the statement. | 579 * The semicolon terminating the statement. |
| 642 */ | 580 */ |
| 643 Token semicolon; | 581 Token semicolon; |
| 644 | 582 |
| 645 /** | 583 /** |
| 646 * Initialize a newly created assert statement. | 584 * Initialize a newly created assert statement. |
| 647 */ | 585 */ |
| 648 AssertStatement( | 586 AssertStatementImpl( |
| 649 this.assertKeyword, | 587 this.assertKeyword, |
| 650 this.leftParenthesis, | 588 this.leftParenthesis, |
| 651 Expression condition, | 589 Expression condition, |
| 652 this.comma, | 590 this.comma, |
| 653 Expression message, | 591 Expression message, |
| 654 this.rightParenthesis, | 592 this.rightParenthesis, |
| 655 this.semicolon) { | 593 this.semicolon) { |
| 656 _condition = _becomeParentOf(condition); | 594 _condition = _becomeParentOf(condition); |
| 657 _message = _becomeParentOf(message); | 595 _message = _becomeParentOf(message); |
| 658 } | 596 } |
| 659 | 597 |
| 660 @override | 598 @override |
| 661 Token get beginToken => assertKeyword; | 599 Token get beginToken => assertKeyword; |
| 662 | 600 |
| 663 @override | 601 @override |
| 664 Iterable get childEntities => new ChildEntities() | 602 Iterable get childEntities => new ChildEntities() |
| 665 ..add(assertKeyword) | 603 ..add(assertKeyword) |
| 666 ..add(leftParenthesis) | 604 ..add(leftParenthesis) |
| 667 ..add(_condition) | 605 ..add(_condition) |
| 668 ..add(comma) | 606 ..add(comma) |
| 669 ..add(_message) | 607 ..add(_message) |
| 670 ..add(rightParenthesis) | 608 ..add(rightParenthesis) |
| 671 ..add(semicolon); | 609 ..add(semicolon); |
| 672 | 610 |
| 673 /** | 611 @override |
| 674 * Return the condition that is being asserted to be `true`. | |
| 675 */ | |
| 676 Expression get condition => _condition; | 612 Expression get condition => _condition; |
| 677 | 613 |
| 678 /** | 614 @override |
| 679 * Set the condition that is being asserted to be `true` to the given | |
| 680 * [expression]. | |
| 681 */ | |
| 682 void set condition(Expression condition) { | 615 void set condition(Expression condition) { |
| 683 _condition = _becomeParentOf(condition); | 616 _condition = _becomeParentOf(condition); |
| 684 } | 617 } |
| 685 | 618 |
| 686 @override | 619 @override |
| 687 Token get endToken => semicolon; | 620 Token get endToken => semicolon; |
| 688 | 621 |
| 689 /** | 622 @override |
| 690 * Return the message to report if the assertion fails. | |
| 691 */ | |
| 692 Expression get message => _message; | 623 Expression get message => _message; |
| 693 | 624 |
| 694 /** | 625 @override |
| 695 * Set the message to report if the assertion fails to the given | |
| 696 * [expression]. | |
| 697 */ | |
| 698 void set message(Expression expression) { | 626 void set message(Expression expression) { |
| 699 _message = _becomeParentOf(expression); | 627 _message = _becomeParentOf(expression); |
| 700 } | 628 } |
| 701 | 629 |
| 702 @override | 630 @override |
| 703 accept(AstVisitor visitor) => visitor.visitAssertStatement(this); | 631 accept(AstVisitor visitor) => visitor.visitAssertStatement(this); |
| 704 | 632 |
| 705 @override | 633 @override |
| 706 void visitChildren(AstVisitor visitor) { | 634 void visitChildren(AstVisitor visitor) { |
| 707 _safelyVisitChild(_condition, visitor); | 635 _safelyVisitChild(_condition, visitor); |
| 708 _safelyVisitChild(message, visitor); | 636 _safelyVisitChild(message, visitor); |
| 709 } | 637 } |
| 710 } | 638 } |
| 711 | 639 |
| 712 /** | 640 /** |
| 713 * An assignment expression. | 641 * An assignment expression. |
| 714 * | 642 * |
| 715 * > assignmentExpression ::= | 643 * > assignmentExpression ::= |
| 716 * > [Expression] operator [Expression] | 644 * > [Expression] operator [Expression] |
| 717 */ | 645 */ |
| 718 class AssignmentExpression extends Expression { | 646 class AssignmentExpressionImpl extends ExpressionImpl |
| 647 implements AssignmentExpression { |
| 719 /** | 648 /** |
| 720 * The expression used to compute the left hand side. | 649 * The expression used to compute the left hand side. |
| 721 */ | 650 */ |
| 722 Expression _leftHandSide; | 651 Expression _leftHandSide; |
| 723 | 652 |
| 724 /** | 653 /** |
| 725 * The assignment operator being applied. | 654 * The assignment operator being applied. |
| 726 */ | 655 */ |
| 727 Token operator; | 656 Token operator; |
| 728 | 657 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 743 * The element associated with the operator based on the propagated type of | 672 * The element associated with the operator based on the propagated type of |
| 744 * the left-hand-side, or `null` if the AST structure has not been resolved, | 673 * the left-hand-side, or `null` if the AST structure has not been resolved, |
| 745 * if the operator is not a compound operator, or if the operator could not be | 674 * if the operator is not a compound operator, or if the operator could not be |
| 746 * resolved. | 675 * resolved. |
| 747 */ | 676 */ |
| 748 MethodElement propagatedElement; | 677 MethodElement propagatedElement; |
| 749 | 678 |
| 750 /** | 679 /** |
| 751 * Initialize a newly created assignment expression. | 680 * Initialize a newly created assignment expression. |
| 752 */ | 681 */ |
| 753 AssignmentExpression( | 682 AssignmentExpressionImpl( |
| 754 Expression leftHandSide, this.operator, Expression rightHandSide) { | 683 Expression leftHandSide, this.operator, Expression rightHandSide) { |
| 755 if (leftHandSide == null || rightHandSide == null) { | 684 if (leftHandSide == null || rightHandSide == null) { |
| 756 String message; | 685 String message; |
| 757 if (leftHandSide == null) { | 686 if (leftHandSide == null) { |
| 758 if (rightHandSide == null) { | 687 if (rightHandSide == null) { |
| 759 message = "Both the left-hand and right-hand sides are null"; | 688 message = "Both the left-hand and right-hand sides are null"; |
| 760 } else { | 689 } else { |
| 761 message = "The left-hand size is null"; | 690 message = "The left-hand size is null"; |
| 762 } | 691 } |
| 763 } else { | 692 } else { |
| 764 message = "The right-hand size is null"; | 693 message = "The right-hand size is null"; |
| 765 } | 694 } |
| 766 AnalysisEngine.instance.logger.logError( | 695 AnalysisEngine.instance.logger.logError( |
| 767 message, new CaughtException(new AnalysisException(message), null)); | 696 message, new CaughtException(new AnalysisException(message), null)); |
| 768 } | 697 } |
| 769 _leftHandSide = _becomeParentOf(leftHandSide); | 698 _leftHandSide = _becomeParentOf(leftHandSide); |
| 770 _rightHandSide = _becomeParentOf(rightHandSide); | 699 _rightHandSide = _becomeParentOf(rightHandSide); |
| 771 } | 700 } |
| 772 | 701 |
| 773 @override | 702 @override |
| 774 Token get beginToken => _leftHandSide.beginToken; | 703 Token get beginToken => _leftHandSide.beginToken; |
| 775 | 704 |
| 776 /** | 705 @override |
| 777 * Return the best element available for this operator. If resolution was able | |
| 778 * to find a better element based on type propagation, that element will be | |
| 779 * returned. Otherwise, the element found using the result of static analysis | |
| 780 * will be returned. If resolution has not been performed, then `null` will be | |
| 781 * returned. | |
| 782 */ | |
| 783 MethodElement get bestElement { | 706 MethodElement get bestElement { |
| 784 MethodElement element = propagatedElement; | 707 MethodElement element = propagatedElement; |
| 785 if (element == null) { | 708 if (element == null) { |
| 786 element = staticElement; | 709 element = staticElement; |
| 787 } | 710 } |
| 788 return element; | 711 return element; |
| 789 } | 712 } |
| 790 | 713 |
| 791 @override | 714 @override |
| 792 Iterable get childEntities => new ChildEntities() | 715 Iterable get childEntities => new ChildEntities() |
| 793 ..add(_leftHandSide) | 716 ..add(_leftHandSide) |
| 794 ..add(operator) | 717 ..add(operator) |
| 795 ..add(_rightHandSide); | 718 ..add(_rightHandSide); |
| 796 | 719 |
| 797 @override | 720 @override |
| 798 Token get endToken => _rightHandSide.endToken; | 721 Token get endToken => _rightHandSide.endToken; |
| 799 | 722 |
| 800 /** | 723 @override |
| 801 * Set the expression used to compute the left hand side to the given | |
| 802 * [expression]. | |
| 803 */ | |
| 804 Expression get leftHandSide => _leftHandSide; | 724 Expression get leftHandSide => _leftHandSide; |
| 805 | 725 |
| 806 /** | 726 @override |
| 807 * Return the expression used to compute the left hand side. | |
| 808 */ | |
| 809 void set leftHandSide(Expression expression) { | 727 void set leftHandSide(Expression expression) { |
| 810 _leftHandSide = _becomeParentOf(expression); | 728 _leftHandSide = _becomeParentOf(expression); |
| 811 } | 729 } |
| 812 | 730 |
| 813 @override | 731 @override |
| 814 int get precedence => 1; | 732 int get precedence => 1; |
| 815 | 733 |
| 816 /** | 734 @override |
| 817 * Return the expression used to compute the right hand side. | |
| 818 */ | |
| 819 Expression get rightHandSide => _rightHandSide; | 735 Expression get rightHandSide => _rightHandSide; |
| 820 | 736 |
| 821 /** | 737 @override |
| 822 * Set the expression used to compute the left hand side to the given | |
| 823 * [expression]. | |
| 824 */ | |
| 825 void set rightHandSide(Expression expression) { | 738 void set rightHandSide(Expression expression) { |
| 826 _rightHandSide = _becomeParentOf(expression); | 739 _rightHandSide = _becomeParentOf(expression); |
| 827 } | 740 } |
| 828 | 741 |
| 829 /** | 742 /** |
| 830 * If the AST structure has been resolved, and the function being invoked is | 743 * If the AST structure has been resolved, and the function being invoked is |
| 831 * known based on propagated type information, then return the parameter | 744 * known based on propagated type information, then return the parameter |
| 832 * element representing the parameter to which the value of the right operand | 745 * element representing the parameter to which the value of the right operand |
| 833 * will be bound. Otherwise, return `null`. | 746 * will be bound. Otherwise, return `null`. |
| 834 */ | 747 */ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 @override | 817 @override |
| 905 void visitChildren(AstVisitor visitor) { | 818 void visitChildren(AstVisitor visitor) { |
| 906 _safelyVisitChild(_leftHandSide, visitor); | 819 _safelyVisitChild(_leftHandSide, visitor); |
| 907 _safelyVisitChild(_rightHandSide, visitor); | 820 _safelyVisitChild(_rightHandSide, visitor); |
| 908 } | 821 } |
| 909 } | 822 } |
| 910 | 823 |
| 911 /** | 824 /** |
| 912 * A node in the AST structure for a Dart program. | 825 * A node in the AST structure for a Dart program. |
| 913 */ | 826 */ |
| 914 abstract class AstNode { | 827 abstract class AstNodeImpl implements AstNode { |
| 915 /** | |
| 916 * An empty list of AST nodes. | |
| 917 */ | |
| 918 static const List<AstNode> EMPTY_LIST = const <AstNode>[]; | |
| 919 | |
| 920 /** | |
| 921 * A comparator that can be used to sort AST nodes in lexical order. In other | |
| 922 * words, `compare` will return a negative value if the offset of the first | |
| 923 * node is less than the offset of the second node, zero (0) if the nodes have | |
| 924 * the same offset, and a positive value if the offset of the first node is | |
| 925 * greater than the offset of the second node. | |
| 926 */ | |
| 927 static Comparator<AstNode> LEXICAL_ORDER = | |
| 928 (AstNode first, AstNode second) => first.offset - second.offset; | |
| 929 | |
| 930 /** | 828 /** |
| 931 * The parent of the node, or `null` if the node is the root of an AST | 829 * The parent of the node, or `null` if the node is the root of an AST |
| 932 * structure. | 830 * structure. |
| 933 */ | 831 */ |
| 934 AstNode _parent; | 832 AstNode _parent; |
| 935 | 833 |
| 936 /** | 834 /** |
| 937 * A table mapping the names of properties to their values, or `null` if this | 835 * A table mapping the names of properties to their values, or `null` if this |
| 938 * node does not have any properties associated with it. | 836 * node does not have any properties associated with it. |
| 939 */ | 837 */ |
| 940 Map<String, Object> _propertyMap; | 838 Map<String, Object> _propertyMap; |
| 941 | 839 |
| 942 /** | 840 @override |
| 943 * Return the first token included in this node's source range. | |
| 944 */ | |
| 945 Token get beginToken; | |
| 946 | |
| 947 /** | |
| 948 * Iterate through all the entities (either AST nodes or tokens) which make | |
| 949 * up the contents of this node, including doc comments but excluding other | |
| 950 * comments. | |
| 951 */ | |
| 952 Iterable /*<AstNode | Token>*/ get childEntities; | |
| 953 | |
| 954 /** | |
| 955 * Return the offset of the character immediately following the last character | |
| 956 * of this node's source range. This is equivalent to | |
| 957 * `node.getOffset() + node.getLength()`. For a compilation unit this will be | |
| 958 * equal to the length of the unit's source. For synthetic nodes this will be | |
| 959 * equivalent to the node's offset (because the length is zero (0) by | |
| 960 * definition). | |
| 961 */ | |
| 962 int get end => offset + length; | 841 int get end => offset + length; |
| 963 | 842 |
| 964 /** | 843 @override |
| 965 * Return the last token included in this node's source range. | |
| 966 */ | |
| 967 Token get endToken; | |
| 968 | |
| 969 /** | |
| 970 * Return `true` if this node is a synthetic node. A synthetic node is a node | |
| 971 * that was introduced by the parser in order to recover from an error in the | |
| 972 * code. Synthetic nodes always have a length of zero (`0`). | |
| 973 */ | |
| 974 bool get isSynthetic => false; | 844 bool get isSynthetic => false; |
| 975 | 845 |
| 976 /** | 846 @override |
| 977 * Return the number of characters in the node's source range. | |
| 978 */ | |
| 979 int get length { | 847 int get length { |
| 980 Token beginToken = this.beginToken; | 848 Token beginToken = this.beginToken; |
| 981 Token endToken = this.endToken; | 849 Token endToken = this.endToken; |
| 982 if (beginToken == null || endToken == null) { | 850 if (beginToken == null || endToken == null) { |
| 983 return -1; | 851 return -1; |
| 984 } | 852 } |
| 985 return endToken.offset + endToken.length - beginToken.offset; | 853 return endToken.offset + endToken.length - beginToken.offset; |
| 986 } | 854 } |
| 987 | 855 |
| 988 /** | 856 @override |
| 989 * Return the offset from the beginning of the file to the first character in | |
| 990 * the node's source range. | |
| 991 */ | |
| 992 int get offset { | 857 int get offset { |
| 993 Token beginToken = this.beginToken; | 858 Token beginToken = this.beginToken; |
| 994 if (beginToken == null) { | 859 if (beginToken == null) { |
| 995 return -1; | 860 return -1; |
| 996 } | 861 } |
| 997 return beginToken.offset; | 862 return beginToken.offset; |
| 998 } | 863 } |
| 999 | 864 |
| 1000 /** | 865 @override |
| 1001 * Return this node's parent node, or `null` if this node is the root of an | |
| 1002 * AST structure. | |
| 1003 * | |
| 1004 * Note that the relationship between an AST node and its parent node may | |
| 1005 * change over the lifetime of a node. | |
| 1006 */ | |
| 1007 AstNode get parent => _parent; | 866 AstNode get parent => _parent; |
| 1008 | 867 |
| 1009 /** | 868 @override |
| 1010 * Return the node at the root of this node's AST structure. Note that this | |
| 1011 * method's performance is linear with respect to the depth of the node in the | |
| 1012 * AST structure (O(depth)). | |
| 1013 */ | |
| 1014 AstNode get root { | 869 AstNode get root { |
| 1015 AstNode root = this; | 870 AstNode root = this; |
| 1016 AstNode parent = this.parent; | 871 AstNode parent = this.parent; |
| 1017 while (parent != null) { | 872 while (parent != null) { |
| 1018 root = parent; | 873 root = parent; |
| 1019 parent = root.parent; | 874 parent = root.parent; |
| 1020 } | 875 } |
| 1021 return root; | 876 return root; |
| 1022 } | 877 } |
| 1023 | 878 |
| 1024 /** | 879 @override |
| 1025 * Use the given [visitor] to visit this node. Return the value returned by | |
| 1026 * the visitor as a result of visiting this node. | |
| 1027 */ | |
| 1028 dynamic /*=E*/ accept /*<E>*/ (AstVisitor /*<E>*/ visitor); | |
| 1029 | |
| 1030 /** | |
| 1031 * Return the most immediate ancestor of this node for which the [predicate] | |
| 1032 * returns `true`, or `null` if there is no such ancestor. Note that this node | |
| 1033 * will never be returned. | |
| 1034 */ | |
| 1035 AstNode getAncestor(Predicate<AstNode> predicate) { | 880 AstNode getAncestor(Predicate<AstNode> predicate) { |
| 1036 // TODO(brianwilkerson) It is a bug that this method can return `this`. | 881 // TODO(brianwilkerson) It is a bug that this method can return `this`. |
| 1037 AstNode node = this; | 882 AstNode node = this; |
| 1038 while (node != null && !predicate(node)) { | 883 while (node != null && !predicate(node)) { |
| 1039 node = node.parent; | 884 node = node.parent; |
| 1040 } | 885 } |
| 1041 return node; | 886 return node; |
| 1042 } | 887 } |
| 1043 | 888 |
| 1044 /** | 889 @override |
| 1045 * Return the value of the property with the given [name], or `null` if this | |
| 1046 * node does not have a property with the given name. | |
| 1047 */ | |
| 1048 Object getProperty(String name) { | 890 Object getProperty(String name) { |
| 1049 if (_propertyMap == null) { | 891 if (_propertyMap == null) { |
| 1050 return null; | 892 return null; |
| 1051 } | 893 } |
| 1052 return _propertyMap[name]; | 894 return _propertyMap[name]; |
| 1053 } | 895 } |
| 1054 | 896 |
| 1055 /** | 897 @override |
| 1056 * Set the value of the property with the given [name] to the given [value]. | |
| 1057 * If the value is `null`, the property will effectively be removed. | |
| 1058 */ | |
| 1059 void setProperty(String name, Object value) { | 898 void setProperty(String name, Object value) { |
| 1060 if (value == null) { | 899 if (value == null) { |
| 1061 if (_propertyMap != null) { | 900 if (_propertyMap != null) { |
| 1062 _propertyMap.remove(name); | 901 _propertyMap.remove(name); |
| 1063 if (_propertyMap.isEmpty) { | 902 if (_propertyMap.isEmpty) { |
| 1064 _propertyMap = null; | 903 _propertyMap = null; |
| 1065 } | 904 } |
| 1066 } | 905 } |
| 1067 } else { | 906 } else { |
| 1068 if (_propertyMap == null) { | 907 if (_propertyMap == null) { |
| 1069 _propertyMap = new HashMap<String, Object>(); | 908 _propertyMap = new HashMap<String, Object>(); |
| 1070 } | 909 } |
| 1071 _propertyMap[name] = value; | 910 _propertyMap[name] = value; |
| 1072 } | 911 } |
| 1073 } | 912 } |
| 1074 | 913 |
| 1075 /** | 914 @override |
| 1076 * Return a textual description of this node in a form approximating valid | |
| 1077 * source. The returned string will not be valid source primarily in the case | |
| 1078 * where the node itself is not well-formed. | |
| 1079 */ | |
| 1080 String toSource() { | 915 String toSource() { |
| 1081 PrintStringWriter writer = new PrintStringWriter(); | 916 PrintStringWriter writer = new PrintStringWriter(); |
| 1082 accept(new ToSourceVisitor(writer)); | 917 accept(new ToSourceVisitor(writer)); |
| 1083 return writer.toString(); | 918 return writer.toString(); |
| 1084 } | 919 } |
| 1085 | 920 |
| 1086 @override | 921 @override |
| 1087 String toString() => toSource(); | 922 String toString() => toSource(); |
| 1088 | 923 |
| 1089 /** | 924 /** |
| 1090 * Use the given [visitor] to visit all of the children of this node. The | |
| 1091 * children will be visited in lexical order. | |
| 1092 */ | |
| 1093 void visitChildren(AstVisitor visitor); | |
| 1094 | |
| 1095 /** | |
| 1096 * Make this node the parent of the given [child] node. Return the child node. | 925 * Make this node the parent of the given [child] node. Return the child node. |
| 1097 */ | 926 */ |
| 1098 AstNode _becomeParentOf(AstNode child) { | 927 AstNode _becomeParentOf(AstNode child) { |
| 1099 if (child != null) { | 928 if (child != null) { |
| 1100 child._parent = this; | 929 (child as AstNodeImpl)._parent = this; |
| 1101 } | 930 } |
| 1102 return child; | 931 return child; |
| 1103 } | 932 } |
| 1104 | 933 |
| 1105 /** | 934 /** |
| 1106 * If the given [child] is not `null`, use the given [visitor] to visit it. | 935 * If the given [child] is not `null`, use the given [visitor] to visit it. |
| 1107 */ | 936 */ |
| 1108 void _safelyVisitChild(AstNode child, AstVisitor visitor) { | 937 void _safelyVisitChild(AstNode child, AstVisitor visitor) { |
| 1109 if (child != null) { | 938 if (child != null) { |
| 1110 child.accept(visitor); | 939 child.accept(visitor); |
| 1111 } | 940 } |
| 1112 } | 941 } |
| 1113 } | 942 } |
| 1114 | 943 |
| 1115 /** | 944 /** |
| 1116 * An object that can be used to visit an AST structure. | |
| 1117 */ | |
| 1118 abstract class AstVisitor<R> { | |
| 1119 R visitAdjacentStrings(AdjacentStrings node); | |
| 1120 | |
| 1121 R visitAnnotation(Annotation node); | |
| 1122 | |
| 1123 R visitArgumentList(ArgumentList node); | |
| 1124 | |
| 1125 R visitAsExpression(AsExpression node); | |
| 1126 | |
| 1127 R visitAssertStatement(AssertStatement assertStatement); | |
| 1128 | |
| 1129 R visitAssignmentExpression(AssignmentExpression node); | |
| 1130 | |
| 1131 R visitAwaitExpression(AwaitExpression node); | |
| 1132 | |
| 1133 R visitBinaryExpression(BinaryExpression node); | |
| 1134 | |
| 1135 R visitBlock(Block node); | |
| 1136 | |
| 1137 R visitBlockFunctionBody(BlockFunctionBody node); | |
| 1138 | |
| 1139 R visitBooleanLiteral(BooleanLiteral node); | |
| 1140 | |
| 1141 R visitBreakStatement(BreakStatement node); | |
| 1142 | |
| 1143 R visitCascadeExpression(CascadeExpression node); | |
| 1144 | |
| 1145 R visitCatchClause(CatchClause node); | |
| 1146 | |
| 1147 R visitClassDeclaration(ClassDeclaration node); | |
| 1148 | |
| 1149 R visitClassTypeAlias(ClassTypeAlias node); | |
| 1150 | |
| 1151 R visitComment(Comment node); | |
| 1152 | |
| 1153 R visitCommentReference(CommentReference node); | |
| 1154 | |
| 1155 R visitCompilationUnit(CompilationUnit node); | |
| 1156 | |
| 1157 R visitConditionalExpression(ConditionalExpression node); | |
| 1158 | |
| 1159 R visitConfiguration(Configuration node); | |
| 1160 | |
| 1161 R visitConstructorDeclaration(ConstructorDeclaration node); | |
| 1162 | |
| 1163 R visitConstructorFieldInitializer(ConstructorFieldInitializer node); | |
| 1164 | |
| 1165 R visitConstructorName(ConstructorName node); | |
| 1166 | |
| 1167 R visitContinueStatement(ContinueStatement node); | |
| 1168 | |
| 1169 R visitDeclaredIdentifier(DeclaredIdentifier node); | |
| 1170 | |
| 1171 R visitDefaultFormalParameter(DefaultFormalParameter node); | |
| 1172 | |
| 1173 R visitDoStatement(DoStatement node); | |
| 1174 | |
| 1175 R visitDottedName(DottedName node); | |
| 1176 | |
| 1177 R visitDoubleLiteral(DoubleLiteral node); | |
| 1178 | |
| 1179 R visitEmptyFunctionBody(EmptyFunctionBody node); | |
| 1180 | |
| 1181 R visitEmptyStatement(EmptyStatement node); | |
| 1182 | |
| 1183 R visitEnumConstantDeclaration(EnumConstantDeclaration node); | |
| 1184 | |
| 1185 R visitEnumDeclaration(EnumDeclaration node); | |
| 1186 | |
| 1187 R visitExportDirective(ExportDirective node); | |
| 1188 | |
| 1189 R visitExpressionFunctionBody(ExpressionFunctionBody node); | |
| 1190 | |
| 1191 R visitExpressionStatement(ExpressionStatement node); | |
| 1192 | |
| 1193 R visitExtendsClause(ExtendsClause node); | |
| 1194 | |
| 1195 R visitFieldDeclaration(FieldDeclaration node); | |
| 1196 | |
| 1197 R visitFieldFormalParameter(FieldFormalParameter node); | |
| 1198 | |
| 1199 R visitForEachStatement(ForEachStatement node); | |
| 1200 | |
| 1201 R visitFormalParameterList(FormalParameterList node); | |
| 1202 | |
| 1203 R visitForStatement(ForStatement node); | |
| 1204 | |
| 1205 R visitFunctionDeclaration(FunctionDeclaration node); | |
| 1206 | |
| 1207 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node); | |
| 1208 | |
| 1209 R visitFunctionExpression(FunctionExpression node); | |
| 1210 | |
| 1211 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node); | |
| 1212 | |
| 1213 R visitFunctionTypeAlias(FunctionTypeAlias functionTypeAlias); | |
| 1214 | |
| 1215 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node); | |
| 1216 | |
| 1217 R visitHideCombinator(HideCombinator node); | |
| 1218 | |
| 1219 R visitIfStatement(IfStatement node); | |
| 1220 | |
| 1221 R visitImplementsClause(ImplementsClause node); | |
| 1222 | |
| 1223 R visitImportDirective(ImportDirective node); | |
| 1224 | |
| 1225 R visitIndexExpression(IndexExpression node); | |
| 1226 | |
| 1227 R visitInstanceCreationExpression(InstanceCreationExpression node); | |
| 1228 | |
| 1229 R visitIntegerLiteral(IntegerLiteral node); | |
| 1230 | |
| 1231 R visitInterpolationExpression(InterpolationExpression node); | |
| 1232 | |
| 1233 R visitInterpolationString(InterpolationString node); | |
| 1234 | |
| 1235 R visitIsExpression(IsExpression node); | |
| 1236 | |
| 1237 R visitLabel(Label node); | |
| 1238 | |
| 1239 R visitLabeledStatement(LabeledStatement node); | |
| 1240 | |
| 1241 R visitLibraryDirective(LibraryDirective node); | |
| 1242 | |
| 1243 R visitLibraryIdentifier(LibraryIdentifier node); | |
| 1244 | |
| 1245 R visitListLiteral(ListLiteral node); | |
| 1246 | |
| 1247 R visitMapLiteral(MapLiteral node); | |
| 1248 | |
| 1249 R visitMapLiteralEntry(MapLiteralEntry node); | |
| 1250 | |
| 1251 R visitMethodDeclaration(MethodDeclaration node); | |
| 1252 | |
| 1253 R visitMethodInvocation(MethodInvocation node); | |
| 1254 | |
| 1255 R visitNamedExpression(NamedExpression node); | |
| 1256 | |
| 1257 R visitNativeClause(NativeClause node); | |
| 1258 | |
| 1259 R visitNativeFunctionBody(NativeFunctionBody node); | |
| 1260 | |
| 1261 R visitNullLiteral(NullLiteral node); | |
| 1262 | |
| 1263 R visitParenthesizedExpression(ParenthesizedExpression node); | |
| 1264 | |
| 1265 R visitPartDirective(PartDirective node); | |
| 1266 | |
| 1267 R visitPartOfDirective(PartOfDirective node); | |
| 1268 | |
| 1269 R visitPostfixExpression(PostfixExpression node); | |
| 1270 | |
| 1271 R visitPrefixedIdentifier(PrefixedIdentifier node); | |
| 1272 | |
| 1273 R visitPrefixExpression(PrefixExpression node); | |
| 1274 | |
| 1275 R visitPropertyAccess(PropertyAccess node); | |
| 1276 | |
| 1277 R visitRedirectingConstructorInvocation( | |
| 1278 RedirectingConstructorInvocation node); | |
| 1279 | |
| 1280 R visitRethrowExpression(RethrowExpression node); | |
| 1281 | |
| 1282 R visitReturnStatement(ReturnStatement node); | |
| 1283 | |
| 1284 R visitScriptTag(ScriptTag node); | |
| 1285 | |
| 1286 R visitShowCombinator(ShowCombinator node); | |
| 1287 | |
| 1288 R visitSimpleFormalParameter(SimpleFormalParameter node); | |
| 1289 | |
| 1290 R visitSimpleIdentifier(SimpleIdentifier node); | |
| 1291 | |
| 1292 R visitSimpleStringLiteral(SimpleStringLiteral node); | |
| 1293 | |
| 1294 R visitStringInterpolation(StringInterpolation node); | |
| 1295 | |
| 1296 R visitSuperConstructorInvocation(SuperConstructorInvocation node); | |
| 1297 | |
| 1298 R visitSuperExpression(SuperExpression node); | |
| 1299 | |
| 1300 R visitSwitchCase(SwitchCase node); | |
| 1301 | |
| 1302 R visitSwitchDefault(SwitchDefault node); | |
| 1303 | |
| 1304 R visitSwitchStatement(SwitchStatement node); | |
| 1305 | |
| 1306 R visitSymbolLiteral(SymbolLiteral node); | |
| 1307 | |
| 1308 R visitThisExpression(ThisExpression node); | |
| 1309 | |
| 1310 R visitThrowExpression(ThrowExpression node); | |
| 1311 | |
| 1312 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node); | |
| 1313 | |
| 1314 R visitTryStatement(TryStatement node); | |
| 1315 | |
| 1316 R visitTypeArgumentList(TypeArgumentList node); | |
| 1317 | |
| 1318 R visitTypeName(TypeName node); | |
| 1319 | |
| 1320 R visitTypeParameter(TypeParameter node); | |
| 1321 | |
| 1322 R visitTypeParameterList(TypeParameterList node); | |
| 1323 | |
| 1324 R visitVariableDeclaration(VariableDeclaration node); | |
| 1325 | |
| 1326 R visitVariableDeclarationList(VariableDeclarationList node); | |
| 1327 | |
| 1328 R visitVariableDeclarationStatement(VariableDeclarationStatement node); | |
| 1329 | |
| 1330 R visitWhileStatement(WhileStatement node); | |
| 1331 | |
| 1332 R visitWithClause(WithClause node); | |
| 1333 | |
| 1334 R visitYieldStatement(YieldStatement node); | |
| 1335 } | |
| 1336 | |
| 1337 /** | |
| 1338 * An await expression. | 945 * An await expression. |
| 1339 * | 946 * |
| 1340 * > awaitExpression ::= | 947 * > awaitExpression ::= |
| 1341 * > 'await' [Expression] | 948 * > 'await' [Expression] |
| 1342 */ | 949 */ |
| 1343 class AwaitExpression extends Expression { | 950 class AwaitExpressionImpl extends ExpressionImpl implements AwaitExpression { |
| 1344 /** | 951 /** |
| 1345 * The 'await' keyword. | 952 * The 'await' keyword. |
| 1346 */ | 953 */ |
| 1347 Token awaitKeyword; | 954 Token awaitKeyword; |
| 1348 | 955 |
| 1349 /** | 956 /** |
| 1350 * The expression whose value is being waited on. | 957 * The expression whose value is being waited on. |
| 1351 */ | 958 */ |
| 1352 Expression _expression; | 959 Expression _expression; |
| 1353 | 960 |
| 1354 /** | 961 /** |
| 1355 * Initialize a newly created await expression. | 962 * Initialize a newly created await expression. |
| 1356 */ | 963 */ |
| 1357 AwaitExpression(this.awaitKeyword, Expression expression) { | 964 AwaitExpressionImpl(this.awaitKeyword, Expression expression) { |
| 1358 _expression = _becomeParentOf(expression); | 965 _expression = _becomeParentOf(expression); |
| 1359 } | 966 } |
| 1360 | 967 |
| 1361 @override | 968 @override |
| 1362 Token get beginToken { | 969 Token get beginToken { |
| 1363 if (awaitKeyword != null) { | 970 if (awaitKeyword != null) { |
| 1364 return awaitKeyword; | 971 return awaitKeyword; |
| 1365 } | 972 } |
| 1366 return _expression.beginToken; | 973 return _expression.beginToken; |
| 1367 } | 974 } |
| 1368 | 975 |
| 1369 @override | 976 @override |
| 1370 Iterable get childEntities => | 977 Iterable get childEntities => |
| 1371 new ChildEntities()..add(awaitKeyword)..add(_expression); | 978 new ChildEntities()..add(awaitKeyword)..add(_expression); |
| 1372 | 979 |
| 1373 @override | 980 @override |
| 1374 Token get endToken => _expression.endToken; | 981 Token get endToken => _expression.endToken; |
| 1375 | 982 |
| 1376 /** | 983 @override |
| 1377 * Return the expression whose value is being waited on. | |
| 1378 */ | |
| 1379 Expression get expression => _expression; | 984 Expression get expression => _expression; |
| 1380 | 985 |
| 1381 /** | 986 @override |
| 1382 * Set the expression whose value is being waited on to the given [expression]
. | |
| 1383 */ | |
| 1384 void set expression(Expression expression) { | 987 void set expression(Expression expression) { |
| 1385 _expression = _becomeParentOf(expression); | 988 _expression = _becomeParentOf(expression); |
| 1386 } | 989 } |
| 1387 | 990 |
| 1388 @override | 991 @override |
| 1389 int get precedence => 0; | 992 int get precedence => 0; |
| 1390 | 993 |
| 1391 @override | 994 @override |
| 1392 accept(AstVisitor visitor) => visitor.visitAwaitExpression(this); | 995 accept(AstVisitor visitor) => visitor.visitAwaitExpression(this); |
| 1393 | 996 |
| 1394 @override | 997 @override |
| 1395 void visitChildren(AstVisitor visitor) { | 998 void visitChildren(AstVisitor visitor) { |
| 1396 _safelyVisitChild(_expression, visitor); | 999 _safelyVisitChild(_expression, visitor); |
| 1397 } | 1000 } |
| 1398 } | 1001 } |
| 1399 | 1002 |
| 1400 /** | 1003 /** |
| 1401 * A binary (infix) expression. | 1004 * A binary (infix) expression. |
| 1402 * | 1005 * |
| 1403 * > binaryExpression ::= | 1006 * > binaryExpression ::= |
| 1404 * > [Expression] [Token] [Expression] | 1007 * > [Expression] [Token] [Expression] |
| 1405 */ | 1008 */ |
| 1406 class BinaryExpression extends Expression { | 1009 class BinaryExpressionImpl extends ExpressionImpl implements BinaryExpression { |
| 1407 /** | 1010 /** |
| 1408 * The expression used to compute the left operand. | 1011 * The expression used to compute the left operand. |
| 1409 */ | 1012 */ |
| 1410 Expression _leftOperand; | 1013 Expression _leftOperand; |
| 1411 | 1014 |
| 1412 /** | 1015 /** |
| 1413 * The binary operator being applied. | 1016 * The binary operator being applied. |
| 1414 */ | 1017 */ |
| 1415 Token operator; | 1018 Token operator; |
| 1416 | 1019 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1430 * The element associated with the operator based on the propagated type of | 1033 * The element associated with the operator based on the propagated type of |
| 1431 * the left operand, or `null` if the AST structure has not been resolved, if | 1034 * the left operand, or `null` if the AST structure has not been resolved, if |
| 1432 * the operator is not user definable, or if the operator could not be | 1035 * the operator is not user definable, or if the operator could not be |
| 1433 * resolved. | 1036 * resolved. |
| 1434 */ | 1037 */ |
| 1435 MethodElement propagatedElement; | 1038 MethodElement propagatedElement; |
| 1436 | 1039 |
| 1437 /** | 1040 /** |
| 1438 * Initialize a newly created binary expression. | 1041 * Initialize a newly created binary expression. |
| 1439 */ | 1042 */ |
| 1440 BinaryExpression( | 1043 BinaryExpressionImpl( |
| 1441 Expression leftOperand, this.operator, Expression rightOperand) { | 1044 Expression leftOperand, this.operator, Expression rightOperand) { |
| 1442 _leftOperand = _becomeParentOf(leftOperand); | 1045 _leftOperand = _becomeParentOf(leftOperand); |
| 1443 _rightOperand = _becomeParentOf(rightOperand); | 1046 _rightOperand = _becomeParentOf(rightOperand); |
| 1444 } | 1047 } |
| 1445 | 1048 |
| 1446 @override | 1049 @override |
| 1447 Token get beginToken => _leftOperand.beginToken; | 1050 Token get beginToken => _leftOperand.beginToken; |
| 1448 | 1051 |
| 1449 /** | 1052 @override |
| 1450 * Return the best element available for this operator. If resolution was able | |
| 1451 * to find a better element based on type propagation, that element will be | |
| 1452 * returned. Otherwise, the element found using the result of static analysis | |
| 1453 * will be returned. If resolution has not been performed, then `null` will be | |
| 1454 * returned. | |
| 1455 */ | |
| 1456 MethodElement get bestElement { | 1053 MethodElement get bestElement { |
| 1457 MethodElement element = propagatedElement; | 1054 MethodElement element = propagatedElement; |
| 1458 if (element == null) { | 1055 if (element == null) { |
| 1459 element = staticElement; | 1056 element = staticElement; |
| 1460 } | 1057 } |
| 1461 return element; | 1058 return element; |
| 1462 } | 1059 } |
| 1463 | 1060 |
| 1464 @override | 1061 @override |
| 1465 Iterable get childEntities => | 1062 Iterable get childEntities => |
| 1466 new ChildEntities()..add(_leftOperand)..add(operator)..add(_rightOperand); | 1063 new ChildEntities()..add(_leftOperand)..add(operator)..add(_rightOperand); |
| 1467 | 1064 |
| 1468 @override | 1065 @override |
| 1469 Token get endToken => _rightOperand.endToken; | 1066 Token get endToken => _rightOperand.endToken; |
| 1470 | 1067 |
| 1471 /** | 1068 @override |
| 1472 * Return the expression used to compute the left operand. | |
| 1473 */ | |
| 1474 Expression get leftOperand => _leftOperand; | 1069 Expression get leftOperand => _leftOperand; |
| 1475 | 1070 |
| 1476 /** | 1071 @override |
| 1477 * Set the expression used to compute the left operand to the given | |
| 1478 * [expression]. | |
| 1479 */ | |
| 1480 void set leftOperand(Expression expression) { | 1072 void set leftOperand(Expression expression) { |
| 1481 _leftOperand = _becomeParentOf(expression); | 1073 _leftOperand = _becomeParentOf(expression); |
| 1482 } | 1074 } |
| 1483 | 1075 |
| 1484 @override | 1076 @override |
| 1485 int get precedence => operator.type.precedence; | 1077 int get precedence => operator.type.precedence; |
| 1486 | 1078 |
| 1487 /** | 1079 @override |
| 1488 * Return the expression used to compute the right operand. | |
| 1489 */ | |
| 1490 Expression get rightOperand => _rightOperand; | 1080 Expression get rightOperand => _rightOperand; |
| 1491 | 1081 |
| 1492 /** | 1082 @override |
| 1493 * Set the expression used to compute the right operand to the given | |
| 1494 * [expression]. | |
| 1495 */ | |
| 1496 void set rightOperand(Expression expression) { | 1083 void set rightOperand(Expression expression) { |
| 1497 _rightOperand = _becomeParentOf(expression); | 1084 _rightOperand = _becomeParentOf(expression); |
| 1498 } | 1085 } |
| 1499 | 1086 |
| 1500 /** | 1087 /** |
| 1501 * If the AST structure has been resolved, and the function being invoked is | 1088 * If the AST structure has been resolved, and the function being invoked is |
| 1502 * known based on propagated type information, then return the parameter | 1089 * known based on propagated type information, then return the parameter |
| 1503 * element representing the parameter to which the value of the right operand | 1090 * element representing the parameter to which the value of the right operand |
| 1504 * will be bound. Otherwise, return `null`. | 1091 * will be bound. Otherwise, return `null`. |
| 1505 */ | 1092 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1535 accept(AstVisitor visitor) => visitor.visitBinaryExpression(this); | 1122 accept(AstVisitor visitor) => visitor.visitBinaryExpression(this); |
| 1536 | 1123 |
| 1537 @override | 1124 @override |
| 1538 void visitChildren(AstVisitor visitor) { | 1125 void visitChildren(AstVisitor visitor) { |
| 1539 _safelyVisitChild(_leftOperand, visitor); | 1126 _safelyVisitChild(_leftOperand, visitor); |
| 1540 _safelyVisitChild(_rightOperand, visitor); | 1127 _safelyVisitChild(_rightOperand, visitor); |
| 1541 } | 1128 } |
| 1542 } | 1129 } |
| 1543 | 1130 |
| 1544 /** | 1131 /** |
| 1545 * A sequence of statements. | |
| 1546 * | |
| 1547 * > block ::= | |
| 1548 * > '{' statement* '}' | |
| 1549 */ | |
| 1550 class Block extends Statement { | |
| 1551 /** | |
| 1552 * The left curly bracket. | |
| 1553 */ | |
| 1554 Token leftBracket; | |
| 1555 | |
| 1556 /** | |
| 1557 * The statements contained in the block. | |
| 1558 */ | |
| 1559 NodeList<Statement> _statements; | |
| 1560 | |
| 1561 /** | |
| 1562 * The right curly bracket. | |
| 1563 */ | |
| 1564 Token rightBracket; | |
| 1565 | |
| 1566 /** | |
| 1567 * Initialize a newly created block of code. | |
| 1568 */ | |
| 1569 Block(this.leftBracket, List<Statement> statements, this.rightBracket) { | |
| 1570 _statements = new NodeList<Statement>(this, statements); | |
| 1571 } | |
| 1572 | |
| 1573 @override | |
| 1574 Token get beginToken => leftBracket; | |
| 1575 | |
| 1576 @override | |
| 1577 Iterable get childEntities => new ChildEntities() | |
| 1578 ..add(leftBracket) | |
| 1579 ..addAll(_statements) | |
| 1580 ..add(rightBracket); | |
| 1581 | |
| 1582 @override | |
| 1583 Token get endToken => rightBracket; | |
| 1584 | |
| 1585 /** | |
| 1586 * Return the statements contained in the block. | |
| 1587 */ | |
| 1588 NodeList<Statement> get statements => _statements; | |
| 1589 | |
| 1590 @override | |
| 1591 accept(AstVisitor visitor) => visitor.visitBlock(this); | |
| 1592 | |
| 1593 @override | |
| 1594 void visitChildren(AstVisitor visitor) { | |
| 1595 _statements.accept(visitor); | |
| 1596 } | |
| 1597 } | |
| 1598 | |
| 1599 /** | |
| 1600 * A function body that consists of a block of statements. | 1132 * A function body that consists of a block of statements. |
| 1601 * | 1133 * |
| 1602 * > blockFunctionBody ::= | 1134 * > blockFunctionBody ::= |
| 1603 * > ('async' | 'async' '*' | 'sync' '*')? [Block] | 1135 * > ('async' | 'async' '*' | 'sync' '*')? [Block] |
| 1604 */ | 1136 */ |
| 1605 class BlockFunctionBody extends FunctionBody { | 1137 class BlockFunctionBodyImpl extends FunctionBodyImpl |
| 1138 implements BlockFunctionBody { |
| 1606 /** | 1139 /** |
| 1607 * The token representing the 'async' or 'sync' keyword, or `null` if there is | 1140 * The token representing the 'async' or 'sync' keyword, or `null` if there is |
| 1608 * no such keyword. | 1141 * no such keyword. |
| 1609 */ | 1142 */ |
| 1610 Token keyword; | 1143 Token keyword; |
| 1611 | 1144 |
| 1612 /** | 1145 /** |
| 1613 * The star optionally following the 'async' or 'sync' keyword, or `null` if | 1146 * The star optionally following the 'async' or 'sync' keyword, or `null` if |
| 1614 * there is wither no such keyword or no star. | 1147 * there is wither no such keyword or no star. |
| 1615 */ | 1148 */ |
| 1616 Token star; | 1149 Token star; |
| 1617 | 1150 |
| 1618 /** | 1151 /** |
| 1619 * The block representing the body of the function. | 1152 * The block representing the body of the function. |
| 1620 */ | 1153 */ |
| 1621 Block _block; | 1154 Block _block; |
| 1622 | 1155 |
| 1623 /** | 1156 /** |
| 1624 * Initialize a newly created function body consisting of a block of | 1157 * Initialize a newly created function body consisting of a block of |
| 1625 * statements. The [keyword] can be `null` if there is no keyword specified | 1158 * statements. The [keyword] can be `null` if there is no keyword specified |
| 1626 * for the block. The [star] can be `null` if there is no star following the | 1159 * for the block. The [star] can be `null` if there is no star following the |
| 1627 * keyword (and must be `null` if there is no keyword). | 1160 * keyword (and must be `null` if there is no keyword). |
| 1628 */ | 1161 */ |
| 1629 BlockFunctionBody(this.keyword, this.star, Block block) { | 1162 BlockFunctionBodyImpl(this.keyword, this.star, Block block) { |
| 1630 _block = _becomeParentOf(block); | 1163 _block = _becomeParentOf(block); |
| 1631 } | 1164 } |
| 1632 | 1165 |
| 1633 @override | 1166 @override |
| 1634 Token get beginToken { | 1167 Token get beginToken { |
| 1635 if (keyword != null) { | 1168 if (keyword != null) { |
| 1636 return keyword; | 1169 return keyword; |
| 1637 } | 1170 } |
| 1638 return _block.beginToken; | 1171 return _block.beginToken; |
| 1639 } | 1172 } |
| 1640 | 1173 |
| 1641 /** | 1174 @override |
| 1642 * Return the block representing the body of the function. | |
| 1643 */ | |
| 1644 Block get block => _block; | 1175 Block get block => _block; |
| 1645 | 1176 |
| 1646 /** | 1177 @override |
| 1647 * Set the block representing the body of the function to the given [block]. | |
| 1648 */ | |
| 1649 void set block(Block block) { | 1178 void set block(Block block) { |
| 1650 _block = _becomeParentOf(block); | 1179 _block = _becomeParentOf(block); |
| 1651 } | 1180 } |
| 1652 | 1181 |
| 1653 @override | 1182 @override |
| 1654 Iterable get childEntities => | 1183 Iterable get childEntities => |
| 1655 new ChildEntities()..add(keyword)..add(star)..add(_block); | 1184 new ChildEntities()..add(keyword)..add(star)..add(_block); |
| 1656 | 1185 |
| 1657 @override | 1186 @override |
| 1658 Token get endToken => _block.endToken; | 1187 Token get endToken => _block.endToken; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1669 @override | 1198 @override |
| 1670 accept(AstVisitor visitor) => visitor.visitBlockFunctionBody(this); | 1199 accept(AstVisitor visitor) => visitor.visitBlockFunctionBody(this); |
| 1671 | 1200 |
| 1672 @override | 1201 @override |
| 1673 void visitChildren(AstVisitor visitor) { | 1202 void visitChildren(AstVisitor visitor) { |
| 1674 _safelyVisitChild(_block, visitor); | 1203 _safelyVisitChild(_block, visitor); |
| 1675 } | 1204 } |
| 1676 } | 1205 } |
| 1677 | 1206 |
| 1678 /** | 1207 /** |
| 1208 * A sequence of statements. |
| 1209 * |
| 1210 * > block ::= |
| 1211 * > '{' statement* '}' |
| 1212 */ |
| 1213 class BlockImpl extends StatementImpl implements Block { |
| 1214 /** |
| 1215 * The left curly bracket. |
| 1216 */ |
| 1217 Token leftBracket; |
| 1218 |
| 1219 /** |
| 1220 * The statements contained in the block. |
| 1221 */ |
| 1222 NodeList<Statement> _statements; |
| 1223 |
| 1224 /** |
| 1225 * The right curly bracket. |
| 1226 */ |
| 1227 Token rightBracket; |
| 1228 |
| 1229 /** |
| 1230 * Initialize a newly created block of code. |
| 1231 */ |
| 1232 BlockImpl(this.leftBracket, List<Statement> statements, this.rightBracket) { |
| 1233 _statements = new NodeList<Statement>(this, statements); |
| 1234 } |
| 1235 |
| 1236 @override |
| 1237 Token get beginToken => leftBracket; |
| 1238 |
| 1239 @override |
| 1240 Iterable get childEntities => new ChildEntities() |
| 1241 ..add(leftBracket) |
| 1242 ..addAll(_statements) |
| 1243 ..add(rightBracket); |
| 1244 |
| 1245 @override |
| 1246 Token get endToken => rightBracket; |
| 1247 |
| 1248 @override |
| 1249 NodeList<Statement> get statements => _statements; |
| 1250 |
| 1251 @override |
| 1252 accept(AstVisitor visitor) => visitor.visitBlock(this); |
| 1253 |
| 1254 @override |
| 1255 void visitChildren(AstVisitor visitor) { |
| 1256 _statements.accept(visitor); |
| 1257 } |
| 1258 } |
| 1259 |
| 1260 /** |
| 1679 * A boolean literal expression. | 1261 * A boolean literal expression. |
| 1680 * | 1262 * |
| 1681 * > booleanLiteral ::= | 1263 * > booleanLiteral ::= |
| 1682 * > 'false' | 'true' | 1264 * > 'false' | 'true' |
| 1683 */ | 1265 */ |
| 1684 class BooleanLiteral extends Literal { | 1266 class BooleanLiteralImpl extends LiteralImpl implements BooleanLiteral { |
| 1685 /** | 1267 /** |
| 1686 * The token representing the literal. | 1268 * The token representing the literal. |
| 1687 */ | 1269 */ |
| 1688 Token literal; | 1270 Token literal; |
| 1689 | 1271 |
| 1690 /** | 1272 /** |
| 1691 * The value of the literal. | 1273 * The value of the literal. |
| 1692 */ | 1274 */ |
| 1693 bool value = false; | 1275 bool value = false; |
| 1694 | 1276 |
| 1695 /** | 1277 /** |
| 1696 * Initialize a newly created boolean literal. | 1278 * Initialize a newly created boolean literal. |
| 1697 */ | 1279 */ |
| 1698 BooleanLiteral(this.literal, this.value); | 1280 BooleanLiteralImpl(this.literal, this.value); |
| 1699 | 1281 |
| 1700 @override | 1282 @override |
| 1701 Token get beginToken => literal; | 1283 Token get beginToken => literal; |
| 1702 | 1284 |
| 1703 @override | 1285 @override |
| 1704 Iterable get childEntities => new ChildEntities()..add(literal); | 1286 Iterable get childEntities => new ChildEntities()..add(literal); |
| 1705 | 1287 |
| 1706 @override | 1288 @override |
| 1707 Token get endToken => literal; | 1289 Token get endToken => literal; |
| 1708 | 1290 |
| 1709 @override | 1291 @override |
| 1710 bool get isSynthetic => literal.isSynthetic; | 1292 bool get isSynthetic => literal.isSynthetic; |
| 1711 | 1293 |
| 1712 @override | 1294 @override |
| 1713 accept(AstVisitor visitor) => visitor.visitBooleanLiteral(this); | 1295 accept(AstVisitor visitor) => visitor.visitBooleanLiteral(this); |
| 1714 | 1296 |
| 1715 @override | 1297 @override |
| 1716 void visitChildren(AstVisitor visitor) { | 1298 void visitChildren(AstVisitor visitor) { |
| 1717 // There are no children to visit. | 1299 // There are no children to visit. |
| 1718 } | 1300 } |
| 1719 } | 1301 } |
| 1720 | 1302 |
| 1721 /** | 1303 /** |
| 1722 * A break statement. | 1304 * A break statement. |
| 1723 * | 1305 * |
| 1724 * > breakStatement ::= | 1306 * > breakStatement ::= |
| 1725 * > 'break' [SimpleIdentifier]? ';' | 1307 * > 'break' [SimpleIdentifier]? ';' |
| 1726 */ | 1308 */ |
| 1727 class BreakStatement extends Statement { | 1309 class BreakStatementImpl extends StatementImpl implements BreakStatement { |
| 1728 /** | 1310 /** |
| 1729 * The token representing the 'break' keyword. | 1311 * The token representing the 'break' keyword. |
| 1730 */ | 1312 */ |
| 1731 Token breakKeyword; | 1313 Token breakKeyword; |
| 1732 | 1314 |
| 1733 /** | 1315 /** |
| 1734 * The label associated with the statement, or `null` if there is no label. | 1316 * The label associated with the statement, or `null` if there is no label. |
| 1735 */ | 1317 */ |
| 1736 SimpleIdentifier _label; | 1318 SimpleIdentifier _label; |
| 1737 | 1319 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1748 * `null` if the AST has not yet been resolved or if the target could not be | 1330 * `null` if the AST has not yet been resolved or if the target could not be |
| 1749 * resolved. Note that if the source code has errors, the target might be | 1331 * resolved. Note that if the source code has errors, the target might be |
| 1750 * invalid (e.g. trying to break to a switch case). | 1332 * invalid (e.g. trying to break to a switch case). |
| 1751 */ | 1333 */ |
| 1752 AstNode target; | 1334 AstNode target; |
| 1753 | 1335 |
| 1754 /** | 1336 /** |
| 1755 * Initialize a newly created break statement. The [label] can be `null` if | 1337 * Initialize a newly created break statement. The [label] can be `null` if |
| 1756 * there is no label associated with the statement. | 1338 * there is no label associated with the statement. |
| 1757 */ | 1339 */ |
| 1758 BreakStatement(this.breakKeyword, SimpleIdentifier label, this.semicolon) { | 1340 BreakStatementImpl( |
| 1341 this.breakKeyword, SimpleIdentifier label, this.semicolon) { |
| 1759 _label = _becomeParentOf(label); | 1342 _label = _becomeParentOf(label); |
| 1760 } | 1343 } |
| 1761 | 1344 |
| 1762 @override | 1345 @override |
| 1763 Token get beginToken => breakKeyword; | 1346 Token get beginToken => breakKeyword; |
| 1764 | 1347 |
| 1765 @override | 1348 @override |
| 1766 Iterable get childEntities => | 1349 Iterable get childEntities => |
| 1767 new ChildEntities()..add(breakKeyword)..add(_label)..add(semicolon); | 1350 new ChildEntities()..add(breakKeyword)..add(_label)..add(semicolon); |
| 1768 | 1351 |
| 1769 @override | 1352 @override |
| 1770 Token get endToken => semicolon; | 1353 Token get endToken => semicolon; |
| 1771 | 1354 |
| 1772 /** | 1355 @override |
| 1773 * Return the label associated with the statement, or `null` if there is no | |
| 1774 * label. | |
| 1775 */ | |
| 1776 SimpleIdentifier get label => _label; | 1356 SimpleIdentifier get label => _label; |
| 1777 | 1357 |
| 1778 /** | 1358 @override |
| 1779 * Set the label associated with the statement to the given [identifier]. | |
| 1780 */ | |
| 1781 void set label(SimpleIdentifier identifier) { | 1359 void set label(SimpleIdentifier identifier) { |
| 1782 _label = _becomeParentOf(identifier); | 1360 _label = _becomeParentOf(identifier); |
| 1783 } | 1361 } |
| 1784 | 1362 |
| 1785 @override | 1363 @override |
| 1786 accept(AstVisitor visitor) => visitor.visitBreakStatement(this); | 1364 accept(AstVisitor visitor) => visitor.visitBreakStatement(this); |
| 1787 | 1365 |
| 1788 @override | 1366 @override |
| 1789 void visitChildren(AstVisitor visitor) { | 1367 void visitChildren(AstVisitor visitor) { |
| 1790 _safelyVisitChild(_label, visitor); | 1368 _safelyVisitChild(_label, visitor); |
| 1791 } | 1369 } |
| 1792 } | 1370 } |
| 1793 | 1371 |
| 1794 /** | 1372 /** |
| 1795 * A sequence of cascaded expressions: expressions that share a common target. | 1373 * A sequence of cascaded expressions: expressions that share a common target. |
| 1796 * There are three kinds of expressions that can be used in a cascade | 1374 * There are three kinds of expressions that can be used in a cascade |
| 1797 * expression: [IndexExpression], [MethodInvocation] and [PropertyAccess]. | 1375 * expression: [IndexExpression], [MethodInvocation] and [PropertyAccess]. |
| 1798 * | 1376 * |
| 1799 * > cascadeExpression ::= | 1377 * > cascadeExpression ::= |
| 1800 * > [Expression] cascadeSection* | 1378 * > [Expression] cascadeSection* |
| 1801 * > | 1379 * > |
| 1802 * > cascadeSection ::= | 1380 * > cascadeSection ::= |
| 1803 * > '..' (cascadeSelector arguments*) (assignableSelector arguments*)* | 1381 * > '..' (cascadeSelector arguments*) (assignableSelector arguments*)* |
| 1804 * > (assignmentOperator expressionWithoutCascade)? | 1382 * > (assignmentOperator expressionWithoutCascade)? |
| 1805 * > | 1383 * > |
| 1806 * > cascadeSelector ::= | 1384 * > cascadeSelector ::= |
| 1807 * > '[ ' expression '] ' | 1385 * > '[ ' expression '] ' |
| 1808 * > | identifier | 1386 * > | identifier |
| 1809 */ | 1387 */ |
| 1810 class CascadeExpression extends Expression { | 1388 class CascadeExpressionImpl extends ExpressionImpl |
| 1389 implements CascadeExpression { |
| 1811 /** | 1390 /** |
| 1812 * The target of the cascade sections. | 1391 * The target of the cascade sections. |
| 1813 */ | 1392 */ |
| 1814 Expression _target; | 1393 Expression _target; |
| 1815 | 1394 |
| 1816 /** | 1395 /** |
| 1817 * The cascade sections sharing the common target. | 1396 * The cascade sections sharing the common target. |
| 1818 */ | 1397 */ |
| 1819 NodeList<Expression> _cascadeSections; | 1398 NodeList<Expression> _cascadeSections; |
| 1820 | 1399 |
| 1821 /** | 1400 /** |
| 1822 * Initialize a newly created cascade expression. The list of | 1401 * Initialize a newly created cascade expression. The list of |
| 1823 * [cascadeSections] must contain at least one element. | 1402 * [cascadeSections] must contain at least one element. |
| 1824 */ | 1403 */ |
| 1825 CascadeExpression(Expression target, List<Expression> cascadeSections) { | 1404 CascadeExpressionImpl(Expression target, List<Expression> cascadeSections) { |
| 1826 _target = _becomeParentOf(target); | 1405 _target = _becomeParentOf(target); |
| 1827 _cascadeSections = new NodeList<Expression>(this, cascadeSections); | 1406 _cascadeSections = new NodeList<Expression>(this, cascadeSections); |
| 1828 } | 1407 } |
| 1829 | 1408 |
| 1830 @override | 1409 @override |
| 1831 Token get beginToken => _target.beginToken; | 1410 Token get beginToken => _target.beginToken; |
| 1832 | 1411 |
| 1833 /** | 1412 @override |
| 1834 * Return the cascade sections sharing the common target. | |
| 1835 */ | |
| 1836 NodeList<Expression> get cascadeSections => _cascadeSections; | 1413 NodeList<Expression> get cascadeSections => _cascadeSections; |
| 1837 | 1414 |
| 1838 @override | 1415 @override |
| 1839 Iterable get childEntities => new ChildEntities() | 1416 Iterable get childEntities => new ChildEntities() |
| 1840 ..add(_target) | 1417 ..add(_target) |
| 1841 ..addAll(_cascadeSections); | 1418 ..addAll(_cascadeSections); |
| 1842 | 1419 |
| 1843 @override | 1420 @override |
| 1844 Token get endToken => _cascadeSections.endToken; | 1421 Token get endToken => _cascadeSections.endToken; |
| 1845 | 1422 |
| 1846 @override | 1423 @override |
| 1847 int get precedence => 2; | 1424 int get precedence => 2; |
| 1848 | 1425 |
| 1849 /** | 1426 @override |
| 1850 * Return the target of the cascade sections. | |
| 1851 */ | |
| 1852 Expression get target => _target; | 1427 Expression get target => _target; |
| 1853 | 1428 |
| 1854 /** | 1429 @override |
| 1855 * Set the target of the cascade sections to the given [expression]. | |
| 1856 */ | |
| 1857 void set target(Expression target) { | 1430 void set target(Expression target) { |
| 1858 _target = _becomeParentOf(target); | 1431 _target = _becomeParentOf(target); |
| 1859 } | 1432 } |
| 1860 | 1433 |
| 1861 @override | 1434 @override |
| 1862 accept(AstVisitor visitor) => visitor.visitCascadeExpression(this); | 1435 accept(AstVisitor visitor) => visitor.visitCascadeExpression(this); |
| 1863 | 1436 |
| 1864 @override | 1437 @override |
| 1865 void visitChildren(AstVisitor visitor) { | 1438 void visitChildren(AstVisitor visitor) { |
| 1866 _safelyVisitChild(_target, visitor); | 1439 _safelyVisitChild(_target, visitor); |
| 1867 _cascadeSections.accept(visitor); | 1440 _cascadeSections.accept(visitor); |
| 1868 } | 1441 } |
| 1869 } | 1442 } |
| 1870 | 1443 |
| 1871 /** | 1444 /** |
| 1872 * A catch clause within a try statement. | 1445 * A catch clause within a try statement. |
| 1873 * | 1446 * |
| 1874 * > onPart ::= | 1447 * > onPart ::= |
| 1875 * > catchPart [Block] | 1448 * > catchPart [Block] |
| 1876 * > | 'on' type catchPart? [Block] | 1449 * > | 'on' type catchPart? [Block] |
| 1877 * > | 1450 * > |
| 1878 * > catchPart ::= | 1451 * > catchPart ::= |
| 1879 * > 'catch' '(' [SimpleIdentifier] (',' [SimpleIdentifier])? ')' | 1452 * > 'catch' '(' [SimpleIdentifier] (',' [SimpleIdentifier])? ')' |
| 1880 */ | 1453 */ |
| 1881 class CatchClause extends AstNode { | 1454 class CatchClauseImpl extends AstNodeImpl implements CatchClause { |
| 1882 /** | 1455 /** |
| 1883 * The token representing the 'on' keyword, or `null` if there is no 'on' | 1456 * The token representing the 'on' keyword, or `null` if there is no 'on' |
| 1884 * keyword. | 1457 * keyword. |
| 1885 */ | 1458 */ |
| 1886 Token onKeyword; | 1459 Token onKeyword; |
| 1887 | 1460 |
| 1888 /** | 1461 /** |
| 1889 * The type of exceptions caught by this catch clause, or `null` if this catch | 1462 * The type of exceptions caught by this catch clause, or `null` if this catch |
| 1890 * clause catches every type of exception. | 1463 * clause catches every type of exception. |
| 1891 */ | 1464 */ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 Token rightParenthesis; | 1499 Token rightParenthesis; |
| 1927 | 1500 |
| 1928 /** | 1501 /** |
| 1929 * The body of the catch block. | 1502 * The body of the catch block. |
| 1930 */ | 1503 */ |
| 1931 Block _body; | 1504 Block _body; |
| 1932 | 1505 |
| 1933 /** | 1506 /** |
| 1934 * Initialize a newly created catch clause. The [onKeyword] and | 1507 * Initialize a newly created catch clause. The [onKeyword] and |
| 1935 * [exceptionType] can be `null` if the clause will catch all exceptions. The | 1508 * [exceptionType] can be `null` if the clause will catch all exceptions. The |
| 1936 * [comma] and [stackTraceParameter] can be `null` if the stack trace is not | 1509 * [comma] and [stackTraceParameter] can be `null` if the stack trace |
| 1937 * referencable within the body. | 1510 * parameter is not defined. |
| 1938 */ | 1511 */ |
| 1939 CatchClause( | 1512 CatchClauseImpl( |
| 1940 this.onKeyword, | 1513 this.onKeyword, |
| 1941 TypeName exceptionType, | 1514 TypeName exceptionType, |
| 1942 this.catchKeyword, | 1515 this.catchKeyword, |
| 1943 this.leftParenthesis, | 1516 this.leftParenthesis, |
| 1944 SimpleIdentifier exceptionParameter, | 1517 SimpleIdentifier exceptionParameter, |
| 1945 this.comma, | 1518 this.comma, |
| 1946 SimpleIdentifier stackTraceParameter, | 1519 SimpleIdentifier stackTraceParameter, |
| 1947 this.rightParenthesis, | 1520 this.rightParenthesis, |
| 1948 Block body) { | 1521 Block body) { |
| 1949 _exceptionType = _becomeParentOf(exceptionType); | 1522 _exceptionType = _becomeParentOf(exceptionType); |
| 1950 _exceptionParameter = _becomeParentOf(exceptionParameter); | 1523 _exceptionParameter = _becomeParentOf(exceptionParameter); |
| 1951 _stackTraceParameter = _becomeParentOf(stackTraceParameter); | 1524 _stackTraceParameter = _becomeParentOf(stackTraceParameter); |
| 1952 _body = _becomeParentOf(body); | 1525 _body = _becomeParentOf(body); |
| 1953 } | 1526 } |
| 1954 | 1527 |
| 1955 @override | 1528 @override |
| 1956 Token get beginToken { | 1529 Token get beginToken { |
| 1957 if (onKeyword != null) { | 1530 if (onKeyword != null) { |
| 1958 return onKeyword; | 1531 return onKeyword; |
| 1959 } | 1532 } |
| 1960 return catchKeyword; | 1533 return catchKeyword; |
| 1961 } | 1534 } |
| 1962 | 1535 |
| 1963 /** | 1536 @override |
| 1964 * Return the body of the catch block. | |
| 1965 */ | |
| 1966 Block get body => _body; | 1537 Block get body => _body; |
| 1967 | 1538 |
| 1968 /** | 1539 @override |
| 1969 * Set the body of the catch block to the given [block]. | |
| 1970 */ | |
| 1971 void set body(Block block) { | 1540 void set body(Block block) { |
| 1972 _body = _becomeParentOf(block); | 1541 _body = _becomeParentOf(block); |
| 1973 } | 1542 } |
| 1974 | 1543 |
| 1975 @override | 1544 @override |
| 1976 Iterable get childEntities => new ChildEntities() | 1545 Iterable get childEntities => new ChildEntities() |
| 1977 ..add(onKeyword) | 1546 ..add(onKeyword) |
| 1978 ..add(_exceptionType) | 1547 ..add(_exceptionType) |
| 1979 ..add(catchKeyword) | 1548 ..add(catchKeyword) |
| 1980 ..add(leftParenthesis) | 1549 ..add(leftParenthesis) |
| 1981 ..add(_exceptionParameter) | 1550 ..add(_exceptionParameter) |
| 1982 ..add(comma) | 1551 ..add(comma) |
| 1983 ..add(_stackTraceParameter) | 1552 ..add(_stackTraceParameter) |
| 1984 ..add(rightParenthesis) | 1553 ..add(rightParenthesis) |
| 1985 ..add(_body); | 1554 ..add(_body); |
| 1986 | 1555 |
| 1987 @override | 1556 @override |
| 1988 Token get endToken => _body.endToken; | 1557 Token get endToken => _body.endToken; |
| 1989 | 1558 |
| 1990 /** | 1559 @override |
| 1991 * Return the parameter whose value will be the exception that was thrown, or | |
| 1992 * `null` if there is no 'catch' keyword. | |
| 1993 */ | |
| 1994 SimpleIdentifier get exceptionParameter => _exceptionParameter; | 1560 SimpleIdentifier get exceptionParameter => _exceptionParameter; |
| 1995 | 1561 |
| 1996 /** | 1562 @override |
| 1997 * Set the parameter whose value will be the exception that was thrown to the | |
| 1998 * given [parameter]. | |
| 1999 */ | |
| 2000 void set exceptionParameter(SimpleIdentifier parameter) { | 1563 void set exceptionParameter(SimpleIdentifier parameter) { |
| 2001 _exceptionParameter = _becomeParentOf(parameter); | 1564 _exceptionParameter = _becomeParentOf(parameter); |
| 2002 } | 1565 } |
| 2003 | 1566 |
| 2004 /** | 1567 @override |
| 2005 * Return the type of exceptions caught by this catch clause, or `null` if | |
| 2006 * this catch clause catches every type of exception. | |
| 2007 */ | |
| 2008 TypeName get exceptionType => _exceptionType; | 1568 TypeName get exceptionType => _exceptionType; |
| 2009 | 1569 |
| 2010 /** | 1570 @override |
| 2011 * Set the type of exceptions caught by this catch clause to the given | |
| 2012 * [exceptionType]. | |
| 2013 */ | |
| 2014 void set exceptionType(TypeName exceptionType) { | 1571 void set exceptionType(TypeName exceptionType) { |
| 2015 _exceptionType = _becomeParentOf(exceptionType); | 1572 _exceptionType = _becomeParentOf(exceptionType); |
| 2016 } | 1573 } |
| 2017 | 1574 |
| 2018 /** | 1575 @override |
| 2019 * Return the parameter whose value will be the stack trace associated with | |
| 2020 * the exception, or `null` if there is no stack trace parameter. | |
| 2021 */ | |
| 2022 SimpleIdentifier get stackTraceParameter => _stackTraceParameter; | 1576 SimpleIdentifier get stackTraceParameter => _stackTraceParameter; |
| 2023 | 1577 |
| 2024 /** | 1578 @override |
| 2025 * Set the parameter whose value will be the stack trace associated with the | |
| 2026 * exception to the given [parameter]. | |
| 2027 */ | |
| 2028 void set stackTraceParameter(SimpleIdentifier parameter) { | 1579 void set stackTraceParameter(SimpleIdentifier parameter) { |
| 2029 _stackTraceParameter = _becomeParentOf(parameter); | 1580 _stackTraceParameter = _becomeParentOf(parameter); |
| 2030 } | 1581 } |
| 2031 | 1582 |
| 2032 @override | 1583 @override |
| 2033 accept(AstVisitor visitor) => visitor.visitCatchClause(this); | 1584 accept(AstVisitor visitor) => visitor.visitCatchClause(this); |
| 2034 | 1585 |
| 2035 @override | 1586 @override |
| 2036 void visitChildren(AstVisitor visitor) { | 1587 void visitChildren(AstVisitor visitor) { |
| 2037 _safelyVisitChild(_exceptionType, visitor); | 1588 _safelyVisitChild(_exceptionType, visitor); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 | 1626 |
| 2076 /** | 1627 /** |
| 2077 * The declaration of a class. | 1628 * The declaration of a class. |
| 2078 * | 1629 * |
| 2079 * > classDeclaration ::= | 1630 * > classDeclaration ::= |
| 2080 * > 'abstract'? 'class' [SimpleIdentifier] [TypeParameterList]? | 1631 * > 'abstract'? 'class' [SimpleIdentifier] [TypeParameterList]? |
| 2081 * > ([ExtendsClause] [WithClause]?)? | 1632 * > ([ExtendsClause] [WithClause]?)? |
| 2082 * > [ImplementsClause]? | 1633 * > [ImplementsClause]? |
| 2083 * > '{' [ClassMember]* '}' | 1634 * > '{' [ClassMember]* '}' |
| 2084 */ | 1635 */ |
| 2085 class ClassDeclaration extends NamedCompilationUnitMember { | 1636 class ClassDeclarationImpl extends NamedCompilationUnitMemberImpl |
| 1637 implements ClassDeclaration { |
| 2086 /** | 1638 /** |
| 2087 * The 'abstract' keyword, or `null` if the keyword was absent. | 1639 * The 'abstract' keyword, or `null` if the keyword was absent. |
| 2088 */ | 1640 */ |
| 2089 Token abstractKeyword; | 1641 Token abstractKeyword; |
| 2090 | 1642 |
| 2091 /** | 1643 /** |
| 2092 * The token representing the 'class' keyword. | 1644 * The token representing the 'class' keyword. |
| 2093 */ | 1645 */ |
| 2094 Token classKeyword; | 1646 Token classKeyword; |
| 2095 | 1647 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 /** | 1693 /** |
| 2142 * Initialize a newly created class declaration. Either or both of the | 1694 * Initialize a newly created class declaration. Either or both of the |
| 2143 * [comment] and [metadata] can be `null` if the class does not have the | 1695 * [comment] and [metadata] can be `null` if the class does not have the |
| 2144 * corresponding attribute. The [abstractKeyword] can be `null` if the class | 1696 * corresponding attribute. The [abstractKeyword] can be `null` if the class |
| 2145 * is not abstract. The [typeParameters] can be `null` if the class does not | 1697 * is not abstract. The [typeParameters] can be `null` if the class does not |
| 2146 * have any type parameters. Any or all of the [extendsClause], [withClause], | 1698 * have any type parameters. Any or all of the [extendsClause], [withClause], |
| 2147 * and [implementsClause] can be `null` if the class does not have the | 1699 * and [implementsClause] can be `null` if the class does not have the |
| 2148 * corresponding clause. The list of [members] can be `null` if the class does | 1700 * corresponding clause. The list of [members] can be `null` if the class does |
| 2149 * not have any members. | 1701 * not have any members. |
| 2150 */ | 1702 */ |
| 2151 ClassDeclaration( | 1703 ClassDeclarationImpl( |
| 2152 Comment comment, | 1704 Comment comment, |
| 2153 List<Annotation> metadata, | 1705 List<Annotation> metadata, |
| 2154 this.abstractKeyword, | 1706 this.abstractKeyword, |
| 2155 this.classKeyword, | 1707 this.classKeyword, |
| 2156 SimpleIdentifier name, | 1708 SimpleIdentifier name, |
| 2157 TypeParameterList typeParameters, | 1709 TypeParameterList typeParameters, |
| 2158 ExtendsClause extendsClause, | 1710 ExtendsClause extendsClause, |
| 2159 WithClause withClause, | 1711 WithClause withClause, |
| 2160 ImplementsClause implementsClause, | 1712 ImplementsClause implementsClause, |
| 2161 this.leftBracket, | 1713 this.leftBracket, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2183 ..addAll(members) | 1735 ..addAll(members) |
| 2184 ..add(rightBracket); | 1736 ..add(rightBracket); |
| 2185 | 1737 |
| 2186 @override | 1738 @override |
| 2187 ClassElement get element => | 1739 ClassElement get element => |
| 2188 _name != null ? (_name.staticElement as ClassElement) : null; | 1740 _name != null ? (_name.staticElement as ClassElement) : null; |
| 2189 | 1741 |
| 2190 @override | 1742 @override |
| 2191 Token get endToken => rightBracket; | 1743 Token get endToken => rightBracket; |
| 2192 | 1744 |
| 2193 /** | 1745 @override |
| 2194 * Return the extends clause for this class, or `null` if the class does not | |
| 2195 * extend any other class. | |
| 2196 */ | |
| 2197 ExtendsClause get extendsClause => _extendsClause; | 1746 ExtendsClause get extendsClause => _extendsClause; |
| 2198 | 1747 |
| 2199 /** | 1748 @override |
| 2200 * Set the extends clause for this class to the given [extendsClause]. | |
| 2201 */ | |
| 2202 void set extendsClause(ExtendsClause extendsClause) { | 1749 void set extendsClause(ExtendsClause extendsClause) { |
| 2203 _extendsClause = _becomeParentOf(extendsClause); | 1750 _extendsClause = _becomeParentOf(extendsClause); |
| 2204 } | 1751 } |
| 2205 | 1752 |
| 2206 @override | 1753 @override |
| 2207 Token get firstTokenAfterCommentAndMetadata { | 1754 Token get firstTokenAfterCommentAndMetadata { |
| 2208 if (abstractKeyword != null) { | 1755 if (abstractKeyword != null) { |
| 2209 return abstractKeyword; | 1756 return abstractKeyword; |
| 2210 } | 1757 } |
| 2211 return classKeyword; | 1758 return classKeyword; |
| 2212 } | 1759 } |
| 2213 | 1760 |
| 2214 /** | 1761 @override |
| 2215 * Return the implements clause for the class, or `null` if the class does not | |
| 2216 * implement any interfaces. | |
| 2217 */ | |
| 2218 ImplementsClause get implementsClause => _implementsClause; | 1762 ImplementsClause get implementsClause => _implementsClause; |
| 2219 | 1763 |
| 2220 /** | 1764 @override |
| 2221 * Set the implements clause for the class to the given [implementsClause]. | |
| 2222 */ | |
| 2223 void set implementsClause(ImplementsClause implementsClause) { | 1765 void set implementsClause(ImplementsClause implementsClause) { |
| 2224 _implementsClause = _becomeParentOf(implementsClause); | 1766 _implementsClause = _becomeParentOf(implementsClause); |
| 2225 } | 1767 } |
| 2226 | 1768 |
| 2227 /** | 1769 @override |
| 2228 * Return `true` if this class is declared to be an abstract class. | |
| 2229 */ | |
| 2230 bool get isAbstract => abstractKeyword != null; | 1770 bool get isAbstract => abstractKeyword != null; |
| 2231 | 1771 |
| 2232 /** | 1772 @override |
| 2233 * Return the members defined by the class. | |
| 2234 */ | |
| 2235 NodeList<ClassMember> get members => _members; | 1773 NodeList<ClassMember> get members => _members; |
| 2236 | 1774 |
| 2237 /** | 1775 @override |
| 2238 * Return the native clause for this class, or `null` if the class does not | |
| 2239 * have a native clause. | |
| 2240 */ | |
| 2241 NativeClause get nativeClause => _nativeClause; | 1776 NativeClause get nativeClause => _nativeClause; |
| 2242 | 1777 |
| 2243 /** | 1778 @override |
| 2244 * Set the native clause for this class to the given [nativeClause]. | |
| 2245 */ | |
| 2246 void set nativeClause(NativeClause nativeClause) { | 1779 void set nativeClause(NativeClause nativeClause) { |
| 2247 _nativeClause = _becomeParentOf(nativeClause); | 1780 _nativeClause = _becomeParentOf(nativeClause); |
| 2248 } | 1781 } |
| 2249 | 1782 |
| 2250 /** | 1783 @override |
| 2251 * Return the type parameters for the class, or `null` if the class does not | |
| 2252 * have any type parameters. | |
| 2253 */ | |
| 2254 TypeParameterList get typeParameters => _typeParameters; | 1784 TypeParameterList get typeParameters => _typeParameters; |
| 2255 | 1785 |
| 2256 /** | 1786 @override |
| 2257 * Set the type parameters for the class to the given list of [typeParameters]
. | |
| 2258 */ | |
| 2259 void set typeParameters(TypeParameterList typeParameters) { | 1787 void set typeParameters(TypeParameterList typeParameters) { |
| 2260 _typeParameters = _becomeParentOf(typeParameters); | 1788 _typeParameters = _becomeParentOf(typeParameters); |
| 2261 } | 1789 } |
| 2262 | 1790 |
| 2263 /** | 1791 @override |
| 2264 * Return the with clause for the class, or `null` if the class does not have | |
| 2265 * a with clause. | |
| 2266 */ | |
| 2267 WithClause get withClause => _withClause; | 1792 WithClause get withClause => _withClause; |
| 2268 | 1793 |
| 2269 /** | 1794 @override |
| 2270 * Set the with clause for the class to the given [withClause]. | |
| 2271 */ | |
| 2272 void set withClause(WithClause withClause) { | 1795 void set withClause(WithClause withClause) { |
| 2273 _withClause = _becomeParentOf(withClause); | 1796 _withClause = _becomeParentOf(withClause); |
| 2274 } | 1797 } |
| 2275 | 1798 |
| 2276 @override | 1799 @override |
| 2277 accept(AstVisitor visitor) => visitor.visitClassDeclaration(this); | 1800 accept(AstVisitor visitor) => visitor.visitClassDeclaration(this); |
| 2278 | 1801 |
| 2279 /** | 1802 @override |
| 2280 * Return the constructor declared in the class with the given [name], or | |
| 2281 * `null` if there is no such constructor. If the [name] is `null` then the | |
| 2282 * default constructor will be searched for. | |
| 2283 */ | |
| 2284 ConstructorDeclaration getConstructor(String name) { | 1803 ConstructorDeclaration getConstructor(String name) { |
| 2285 for (ClassMember classMember in _members) { | 1804 for (ClassMember classMember in _members) { |
| 2286 if (classMember is ConstructorDeclaration) { | 1805 if (classMember is ConstructorDeclaration) { |
| 2287 ConstructorDeclaration constructor = classMember; | 1806 ConstructorDeclaration constructor = classMember; |
| 2288 SimpleIdentifier constructorName = constructor.name; | 1807 SimpleIdentifier constructorName = constructor.name; |
| 2289 if (name == null && constructorName == null) { | 1808 if (name == null && constructorName == null) { |
| 2290 return constructor; | 1809 return constructor; |
| 2291 } | 1810 } |
| 2292 if (constructorName != null && constructorName.name == name) { | 1811 if (constructorName != null && constructorName.name == name) { |
| 2293 return constructor; | 1812 return constructor; |
| 2294 } | 1813 } |
| 2295 } | 1814 } |
| 2296 } | 1815 } |
| 2297 return null; | 1816 return null; |
| 2298 } | 1817 } |
| 2299 | 1818 |
| 2300 /** | 1819 @override |
| 2301 * Return the field declared in the class with the given [name], or `null` if | |
| 2302 * there is no such field. | |
| 2303 */ | |
| 2304 VariableDeclaration getField(String name) { | 1820 VariableDeclaration getField(String name) { |
| 2305 for (ClassMember classMember in _members) { | 1821 for (ClassMember classMember in _members) { |
| 2306 if (classMember is FieldDeclaration) { | 1822 if (classMember is FieldDeclaration) { |
| 2307 FieldDeclaration fieldDeclaration = classMember; | 1823 FieldDeclaration fieldDeclaration = classMember; |
| 2308 NodeList<VariableDeclaration> fields = | 1824 NodeList<VariableDeclaration> fields = |
| 2309 fieldDeclaration.fields.variables; | 1825 fieldDeclaration.fields.variables; |
| 2310 for (VariableDeclaration field in fields) { | 1826 for (VariableDeclaration field in fields) { |
| 2311 SimpleIdentifier fieldName = field.name; | 1827 SimpleIdentifier fieldName = field.name; |
| 2312 if (fieldName != null && name == fieldName.name) { | 1828 if (fieldName != null && name == fieldName.name) { |
| 2313 return field; | 1829 return field; |
| 2314 } | 1830 } |
| 2315 } | 1831 } |
| 2316 } | 1832 } |
| 2317 } | 1833 } |
| 2318 return null; | 1834 return null; |
| 2319 } | 1835 } |
| 2320 | 1836 |
| 2321 /** | 1837 @override |
| 2322 * Return the method declared in the class with the given [name], or `null` if | |
| 2323 * there is no such method. | |
| 2324 */ | |
| 2325 MethodDeclaration getMethod(String name) { | 1838 MethodDeclaration getMethod(String name) { |
| 2326 for (ClassMember classMember in _members) { | 1839 for (ClassMember classMember in _members) { |
| 2327 if (classMember is MethodDeclaration) { | 1840 if (classMember is MethodDeclaration) { |
| 2328 MethodDeclaration method = classMember; | 1841 MethodDeclaration method = classMember; |
| 2329 SimpleIdentifier methodName = method.name; | 1842 SimpleIdentifier methodName = method.name; |
| 2330 if (methodName != null && name == methodName.name) { | 1843 if (methodName != null && name == methodName.name) { |
| 2331 return method; | 1844 return method; |
| 2332 } | 1845 } |
| 2333 } | 1846 } |
| 2334 } | 1847 } |
| 2335 return null; | 1848 return null; |
| 2336 } | 1849 } |
| 2337 | 1850 |
| 2338 @override | 1851 @override |
| 2339 void visitChildren(AstVisitor visitor) { | 1852 void visitChildren(AstVisitor visitor) { |
| 2340 super.visitChildren(visitor); | 1853 super.visitChildren(visitor); |
| 2341 _safelyVisitChild(_name, visitor); | 1854 _safelyVisitChild(_name, visitor); |
| 2342 _safelyVisitChild(_typeParameters, visitor); | 1855 _safelyVisitChild(_typeParameters, visitor); |
| 2343 _safelyVisitChild(_extendsClause, visitor); | 1856 _safelyVisitChild(_extendsClause, visitor); |
| 2344 _safelyVisitChild(_withClause, visitor); | 1857 _safelyVisitChild(_withClause, visitor); |
| 2345 _safelyVisitChild(_implementsClause, visitor); | 1858 _safelyVisitChild(_implementsClause, visitor); |
| 2346 _safelyVisitChild(_nativeClause, visitor); | 1859 _safelyVisitChild(_nativeClause, visitor); |
| 2347 members.accept(visitor); | 1860 members.accept(visitor); |
| 2348 } | 1861 } |
| 2349 } | 1862 } |
| 2350 | 1863 |
| 2351 /** | 1864 /** |
| 2352 * A node that declares a name within the scope of a class. | 1865 * A node that declares a name within the scope of a class. |
| 2353 */ | 1866 */ |
| 2354 abstract class ClassMember extends Declaration { | 1867 abstract class ClassMemberImpl extends DeclarationImpl implements ClassMember { |
| 2355 /** | 1868 /** |
| 2356 * Initialize a newly created member of a class. Either or both of the | 1869 * Initialize a newly created member of a class. Either or both of the |
| 2357 * [comment] and [metadata] can be `null` if the member does not have the | 1870 * [comment] and [metadata] can be `null` if the member does not have the |
| 2358 * corresponding attribute. | 1871 * corresponding attribute. |
| 2359 */ | 1872 */ |
| 2360 ClassMember(Comment comment, List<Annotation> metadata) | 1873 ClassMemberImpl(Comment comment, List<Annotation> metadata) |
| 2361 : super(comment, metadata); | 1874 : super(comment, metadata); |
| 2362 } | 1875 } |
| 2363 | 1876 |
| 2364 /** | 1877 /** |
| 2365 * A class type alias. | 1878 * A class type alias. |
| 2366 * | 1879 * |
| 2367 * > classTypeAlias ::= | 1880 * > classTypeAlias ::= |
| 2368 * > [SimpleIdentifier] [TypeParameterList]? '=' 'abstract'? mixinApplicatio
n | 1881 * > [SimpleIdentifier] [TypeParameterList]? '=' 'abstract'? mixinApplicatio
n |
| 2369 * > | 1882 * > |
| 2370 * > mixinApplication ::= | 1883 * > mixinApplication ::= |
| 2371 * > [TypeName] [WithClause] [ImplementsClause]? ';' | 1884 * > [TypeName] [WithClause] [ImplementsClause]? ';' |
| 2372 */ | 1885 */ |
| 2373 class ClassTypeAlias extends TypeAlias { | 1886 class ClassTypeAliasImpl extends TypeAliasImpl implements ClassTypeAlias { |
| 2374 /** | 1887 /** |
| 2375 * The type parameters for the class, or `null` if the class does not have any | 1888 * The type parameters for the class, or `null` if the class does not have any |
| 2376 * type parameters. | 1889 * type parameters. |
| 2377 */ | 1890 */ |
| 2378 TypeParameterList _typeParameters; | 1891 TypeParameterList _typeParameters; |
| 2379 | 1892 |
| 2380 /** | 1893 /** |
| 2381 * The token for the '=' separating the name from the definition. | 1894 * The token for the '=' separating the name from the definition. |
| 2382 */ | 1895 */ |
| 2383 Token equals; | 1896 Token equals; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2405 ImplementsClause _implementsClause; | 1918 ImplementsClause _implementsClause; |
| 2406 | 1919 |
| 2407 /** | 1920 /** |
| 2408 * Initialize a newly created class type alias. Either or both of the | 1921 * Initialize a newly created class type alias. Either or both of the |
| 2409 * [comment] and [metadata] can be `null` if the class type alias does not | 1922 * [comment] and [metadata] can be `null` if the class type alias does not |
| 2410 * have the corresponding attribute. The [typeParameters] can be `null` if the | 1923 * have the corresponding attribute. The [typeParameters] can be `null` if the |
| 2411 * class does not have any type parameters. The [abstractKeyword] can be | 1924 * class does not have any type parameters. The [abstractKeyword] can be |
| 2412 * `null` if the class is not abstract. The [implementsClause] can be `null` | 1925 * `null` if the class is not abstract. The [implementsClause] can be `null` |
| 2413 * if the class does not implement any interfaces. | 1926 * if the class does not implement any interfaces. |
| 2414 */ | 1927 */ |
| 2415 ClassTypeAlias( | 1928 ClassTypeAliasImpl( |
| 2416 Comment comment, | 1929 Comment comment, |
| 2417 List<Annotation> metadata, | 1930 List<Annotation> metadata, |
| 2418 Token keyword, | 1931 Token keyword, |
| 2419 SimpleIdentifier name, | 1932 SimpleIdentifier name, |
| 2420 TypeParameterList typeParameters, | 1933 TypeParameterList typeParameters, |
| 2421 this.equals, | 1934 this.equals, |
| 2422 this.abstractKeyword, | 1935 this.abstractKeyword, |
| 2423 TypeName superclass, | 1936 TypeName superclass, |
| 2424 WithClause withClause, | 1937 WithClause withClause, |
| 2425 ImplementsClause implementsClause, | 1938 ImplementsClause implementsClause, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2440 ..add(abstractKeyword) | 1953 ..add(abstractKeyword) |
| 2441 ..add(_superclass) | 1954 ..add(_superclass) |
| 2442 ..add(_withClause) | 1955 ..add(_withClause) |
| 2443 ..add(_implementsClause) | 1956 ..add(_implementsClause) |
| 2444 ..add(semicolon); | 1957 ..add(semicolon); |
| 2445 | 1958 |
| 2446 @override | 1959 @override |
| 2447 ClassElement get element => | 1960 ClassElement get element => |
| 2448 _name != null ? (_name.staticElement as ClassElement) : null; | 1961 _name != null ? (_name.staticElement as ClassElement) : null; |
| 2449 | 1962 |
| 2450 /** | 1963 @override |
| 2451 * Return the implements clause for this class, or `null` if there is no | |
| 2452 * implements clause. | |
| 2453 */ | |
| 2454 ImplementsClause get implementsClause => _implementsClause; | 1964 ImplementsClause get implementsClause => _implementsClause; |
| 2455 | 1965 |
| 2456 /** | 1966 @override |
| 2457 * Set the implements clause for this class to the given [implementsClause]. | |
| 2458 */ | |
| 2459 void set implementsClause(ImplementsClause implementsClause) { | 1967 void set implementsClause(ImplementsClause implementsClause) { |
| 2460 _implementsClause = _becomeParentOf(implementsClause); | 1968 _implementsClause = _becomeParentOf(implementsClause); |
| 2461 } | 1969 } |
| 2462 | 1970 |
| 2463 /** | 1971 @override |
| 2464 * Return `true` if this class is declared to be an abstract class. | |
| 2465 */ | |
| 2466 bool get isAbstract => abstractKeyword != null; | 1972 bool get isAbstract => abstractKeyword != null; |
| 2467 | 1973 |
| 2468 /** | 1974 @override |
| 2469 * Return the name of the superclass of the class being declared. | |
| 2470 */ | |
| 2471 TypeName get superclass => _superclass; | 1975 TypeName get superclass => _superclass; |
| 2472 | 1976 |
| 2473 /** | 1977 @override |
| 2474 * Set the name of the superclass of the class being declared to the given | |
| 2475 * [superclass] name. | |
| 2476 */ | |
| 2477 void set superclass(TypeName superclass) { | 1978 void set superclass(TypeName superclass) { |
| 2478 _superclass = _becomeParentOf(superclass); | 1979 _superclass = _becomeParentOf(superclass); |
| 2479 } | 1980 } |
| 2480 | 1981 |
| 2481 /** | 1982 @override |
| 2482 * Return the type parameters for the class, or `null` if the class does not | |
| 2483 * have any type parameters. | |
| 2484 */ | |
| 2485 TypeParameterList get typeParameters => _typeParameters; | 1983 TypeParameterList get typeParameters => _typeParameters; |
| 2486 | 1984 |
| 2487 /** | 1985 @override |
| 2488 * Set the type parameters for the class to the given list of [typeParameters]
. | |
| 2489 */ | |
| 2490 void set typeParameters(TypeParameterList typeParameters) { | 1986 void set typeParameters(TypeParameterList typeParameters) { |
| 2491 _typeParameters = _becomeParentOf(typeParameters); | 1987 _typeParameters = _becomeParentOf(typeParameters); |
| 2492 } | 1988 } |
| 2493 | 1989 |
| 2494 /** | 1990 @override |
| 2495 * Return the with clause for this class. | |
| 2496 */ | |
| 2497 WithClause get withClause => _withClause; | 1991 WithClause get withClause => _withClause; |
| 2498 | 1992 |
| 2499 /** | 1993 @override |
| 2500 * Set the with clause for this class to the given with [withClause]. | |
| 2501 */ | |
| 2502 void set withClause(WithClause withClause) { | 1994 void set withClause(WithClause withClause) { |
| 2503 _withClause = _becomeParentOf(withClause); | 1995 _withClause = _becomeParentOf(withClause); |
| 2504 } | 1996 } |
| 2505 | 1997 |
| 2506 @override | 1998 @override |
| 2507 accept(AstVisitor visitor) => visitor.visitClassTypeAlias(this); | 1999 accept(AstVisitor visitor) => visitor.visitClassTypeAlias(this); |
| 2508 | 2000 |
| 2509 @override | 2001 @override |
| 2510 void visitChildren(AstVisitor visitor) { | 2002 void visitChildren(AstVisitor visitor) { |
| 2511 super.visitChildren(visitor); | 2003 super.visitChildren(visitor); |
| 2512 _safelyVisitChild(_name, visitor); | 2004 _safelyVisitChild(_name, visitor); |
| 2513 _safelyVisitChild(_typeParameters, visitor); | 2005 _safelyVisitChild(_typeParameters, visitor); |
| 2514 _safelyVisitChild(_superclass, visitor); | 2006 _safelyVisitChild(_superclass, visitor); |
| 2515 _safelyVisitChild(_withClause, visitor); | 2007 _safelyVisitChild(_withClause, visitor); |
| 2516 _safelyVisitChild(_implementsClause, visitor); | 2008 _safelyVisitChild(_implementsClause, visitor); |
| 2517 } | 2009 } |
| 2518 } | 2010 } |
| 2519 | 2011 |
| 2520 /** | 2012 /** |
| 2521 * A combinator associated with an import or export directive. | 2013 * A combinator associated with an import or export directive. |
| 2522 * | 2014 * |
| 2523 * > combinator ::= | 2015 * > combinator ::= |
| 2524 * > [HideCombinator] | 2016 * > [HideCombinator] |
| 2525 * > | [ShowCombinator] | 2017 * > | [ShowCombinator] |
| 2526 */ | 2018 */ |
| 2527 abstract class Combinator extends AstNode { | 2019 abstract class CombinatorImpl extends AstNodeImpl implements Combinator { |
| 2528 /** | 2020 /** |
| 2529 * The 'hide' or 'show' keyword specifying what kind of processing is to be | 2021 * The 'hide' or 'show' keyword specifying what kind of processing is to be |
| 2530 * done on the names. | 2022 * done on the names. |
| 2531 */ | 2023 */ |
| 2532 Token keyword; | 2024 Token keyword; |
| 2533 | 2025 |
| 2534 /** | 2026 /** |
| 2535 * Initialize a newly created combinator. | 2027 * Initialize a newly created combinator. |
| 2536 */ | 2028 */ |
| 2537 Combinator(this.keyword); | 2029 CombinatorImpl(this.keyword); |
| 2538 | 2030 |
| 2539 @override | 2031 @override |
| 2540 Token get beginToken => keyword; | 2032 Token get beginToken => keyword; |
| 2541 } | 2033 } |
| 2542 | 2034 |
| 2543 /** | 2035 /** |
| 2544 * A comment within the source code. | 2036 * A comment within the source code. |
| 2545 * | 2037 * |
| 2546 * > comment ::= | 2038 * > comment ::= |
| 2547 * > endOfLineComment | 2039 * > endOfLineComment |
| 2548 * > | blockComment | 2040 * > | blockComment |
| 2549 * > | documentationComment | 2041 * > | documentationComment |
| 2550 * > | 2042 * > |
| 2551 * > endOfLineComment ::= | 2043 * > endOfLineComment ::= |
| 2552 * > '//' (CHARACTER - EOL)* EOL | 2044 * > '//' (CHARACTER - EOL)* EOL |
| 2553 * > | 2045 * > |
| 2554 * > blockComment ::= | 2046 * > blockComment ::= |
| 2555 * > '/ *' CHARACTER* '*/' | 2047 * > '/ *' CHARACTER* '*/' |
| 2556 * > | 2048 * > |
| 2557 * > documentationComment ::= | 2049 * > documentationComment ::= |
| 2558 * > '/ **' (CHARACTER | [CommentReference])* '*/' | 2050 * > '/ **' (CHARACTER | [CommentReference])* '*/' |
| 2559 * > | ('///' (CHARACTER - EOL)* EOL)+ | 2051 * > | ('///' (CHARACTER - EOL)* EOL)+ |
| 2560 */ | 2052 */ |
| 2561 class Comment extends AstNode { | 2053 class CommentImpl extends AstNodeImpl implements Comment { |
| 2562 /** | 2054 /** |
| 2563 * The tokens representing the comment. | 2055 * The tokens representing the comment. |
| 2564 */ | 2056 */ |
| 2565 final List<Token> tokens; | 2057 final List<Token> tokens; |
| 2566 | 2058 |
| 2567 /** | 2059 /** |
| 2568 * The type of the comment. | 2060 * The type of the comment. |
| 2569 */ | 2061 */ |
| 2570 final CommentType _type; | 2062 final CommentType _type; |
| 2571 | 2063 |
| 2572 /** | 2064 /** |
| 2573 * The references embedded within the documentation comment. This list will be | 2065 * The references embedded within the documentation comment. This list will be |
| 2574 * empty unless this is a documentation comment that has references embedded | 2066 * empty unless this is a documentation comment that has references embedded |
| 2575 * within it. | 2067 * within it. |
| 2576 */ | 2068 */ |
| 2577 NodeList<CommentReference> _references; | 2069 NodeList<CommentReference> _references; |
| 2578 | 2070 |
| 2579 /** | 2071 /** |
| 2580 * Initialize a newly created comment. The list of [tokens] must contain at | 2072 * Initialize a newly created comment. The list of [tokens] must contain at |
| 2581 * least one token. The [type] is the type of the comment. The list of | 2073 * least one token. The [type] is the type of the comment. The list of |
| 2582 * [references] can be empty if the comment does not contain any embedded | 2074 * [references] can be empty if the comment does not contain any embedded |
| 2583 * references. | 2075 * references. |
| 2584 */ | 2076 */ |
| 2585 Comment(this.tokens, this._type, List<CommentReference> references) { | 2077 CommentImpl(this.tokens, this._type, List<CommentReference> references) { |
| 2586 _references = new NodeList<CommentReference>(this, references); | 2078 _references = new NodeList<CommentReference>(this, references); |
| 2587 } | 2079 } |
| 2588 | 2080 |
| 2589 @override | 2081 @override |
| 2590 Token get beginToken => tokens[0]; | 2082 Token get beginToken => tokens[0]; |
| 2591 | 2083 |
| 2592 @override | 2084 @override |
| 2593 Iterable get childEntities => new ChildEntities()..addAll(tokens); | 2085 Iterable get childEntities => new ChildEntities()..addAll(tokens); |
| 2594 | 2086 |
| 2595 @override | 2087 @override |
| 2596 Token get endToken => tokens[tokens.length - 1]; | 2088 Token get endToken => tokens[tokens.length - 1]; |
| 2597 | 2089 |
| 2598 /** | 2090 @override |
| 2599 * Return `true` if this is a block comment. | |
| 2600 */ | |
| 2601 bool get isBlock => _type == CommentType.BLOCK; | 2091 bool get isBlock => _type == CommentType.BLOCK; |
| 2602 | 2092 |
| 2603 /** | 2093 @override |
| 2604 * Return `true` if this is a documentation comment. | |
| 2605 */ | |
| 2606 bool get isDocumentation => _type == CommentType.DOCUMENTATION; | 2094 bool get isDocumentation => _type == CommentType.DOCUMENTATION; |
| 2607 | 2095 |
| 2608 /** | 2096 @override |
| 2609 * Return `true` if this is an end-of-line comment. | |
| 2610 */ | |
| 2611 bool get isEndOfLine => _type == CommentType.END_OF_LINE; | 2097 bool get isEndOfLine => _type == CommentType.END_OF_LINE; |
| 2612 | 2098 |
| 2613 /** | 2099 @override |
| 2614 * Return the references embedded within the documentation comment. | |
| 2615 */ | |
| 2616 NodeList<CommentReference> get references => _references; | 2100 NodeList<CommentReference> get references => _references; |
| 2617 | 2101 |
| 2618 @override | 2102 @override |
| 2619 accept(AstVisitor visitor) => visitor.visitComment(this); | 2103 accept(AstVisitor visitor) => visitor.visitComment(this); |
| 2620 | 2104 |
| 2621 @override | 2105 @override |
| 2622 void visitChildren(AstVisitor visitor) { | 2106 void visitChildren(AstVisitor visitor) { |
| 2623 _references.accept(visitor); | 2107 _references.accept(visitor); |
| 2624 } | 2108 } |
| 2625 | 2109 |
| 2626 /** | 2110 /** |
| 2627 * Create a block comment consisting of the given [tokens]. | 2111 * Create a block comment consisting of the given [tokens]. |
| 2628 */ | 2112 */ |
| 2629 static Comment createBlockComment(List<Token> tokens) => | 2113 static Comment createBlockComment(List<Token> tokens) => |
| 2630 new Comment(tokens, CommentType.BLOCK, null); | 2114 new CommentImpl(tokens, CommentType.BLOCK, null); |
| 2631 | 2115 |
| 2632 /** | 2116 /** |
| 2633 * Create a documentation comment consisting of the given [tokens]. | 2117 * Create a documentation comment consisting of the given [tokens]. |
| 2634 */ | 2118 */ |
| 2635 static Comment createDocumentationComment(List<Token> tokens) => new Comment( | 2119 static Comment createDocumentationComment(List<Token> tokens) => |
| 2636 tokens, CommentType.DOCUMENTATION, new List<CommentReference>()); | 2120 new CommentImpl( |
| 2121 tokens, CommentType.DOCUMENTATION, new List<CommentReference>()); |
| 2637 | 2122 |
| 2638 /** | 2123 /** |
| 2639 * Create a documentation comment consisting of the given [tokens] and having | 2124 * Create a documentation comment consisting of the given [tokens] and having |
| 2640 * the given [references] embedded within it. | 2125 * the given [references] embedded within it. |
| 2641 */ | 2126 */ |
| 2642 static Comment createDocumentationCommentWithReferences( | 2127 static Comment createDocumentationCommentWithReferences( |
| 2643 List<Token> tokens, List<CommentReference> references) => | 2128 List<Token> tokens, List<CommentReference> references) => |
| 2644 new Comment(tokens, CommentType.DOCUMENTATION, references); | 2129 new CommentImpl(tokens, CommentType.DOCUMENTATION, references); |
| 2645 | 2130 |
| 2646 /** | 2131 /** |
| 2647 * Create an end-of-line comment consisting of the given [tokens]. | 2132 * Create an end-of-line comment consisting of the given [tokens]. |
| 2648 */ | 2133 */ |
| 2649 static Comment createEndOfLineComment(List<Token> tokens) => | 2134 static Comment createEndOfLineComment(List<Token> tokens) => |
| 2650 new Comment(tokens, CommentType.END_OF_LINE, null); | 2135 new CommentImpl(tokens, CommentType.END_OF_LINE, null); |
| 2651 } | 2136 } |
| 2652 | 2137 |
| 2653 /** | 2138 /** |
| 2654 * A reference to a Dart element that is found within a documentation comment. | 2139 * A reference to a Dart element that is found within a documentation comment. |
| 2655 * | 2140 * |
| 2656 * > commentReference ::= | 2141 * > commentReference ::= |
| 2657 * > '[' 'new'? [Identifier] ']' | 2142 * > '[' 'new'? [Identifier] ']' |
| 2658 */ | 2143 */ |
| 2659 class CommentReference extends AstNode { | 2144 class CommentReferenceImpl extends AstNodeImpl implements CommentReference { |
| 2660 /** | 2145 /** |
| 2661 * The token representing the 'new' keyword, or `null` if there was no 'new' | 2146 * The token representing the 'new' keyword, or `null` if there was no 'new' |
| 2662 * keyword. | 2147 * keyword. |
| 2663 */ | 2148 */ |
| 2664 Token newKeyword; | 2149 Token newKeyword; |
| 2665 | 2150 |
| 2666 /** | 2151 /** |
| 2667 * The identifier being referenced. | 2152 * The identifier being referenced. |
| 2668 */ | 2153 */ |
| 2669 Identifier _identifier; | 2154 Identifier _identifier; |
| 2670 | 2155 |
| 2671 /** | 2156 /** |
| 2672 * Initialize a newly created reference to a Dart element. The [newKeyword] | 2157 * Initialize a newly created reference to a Dart element. The [newKeyword] |
| 2673 * can be `null` if the reference is not to a constructor. | 2158 * can be `null` if the reference is not to a constructor. |
| 2674 */ | 2159 */ |
| 2675 CommentReference(this.newKeyword, Identifier identifier) { | 2160 CommentReferenceImpl(this.newKeyword, Identifier identifier) { |
| 2676 _identifier = _becomeParentOf(identifier); | 2161 _identifier = _becomeParentOf(identifier); |
| 2677 } | 2162 } |
| 2678 | 2163 |
| 2679 @override | 2164 @override |
| 2680 Token get beginToken => _identifier.beginToken; | 2165 Token get beginToken => _identifier.beginToken; |
| 2681 | 2166 |
| 2682 @override | 2167 @override |
| 2683 Iterable get childEntities => | 2168 Iterable get childEntities => |
| 2684 new ChildEntities()..add(newKeyword)..add(_identifier); | 2169 new ChildEntities()..add(newKeyword)..add(_identifier); |
| 2685 | 2170 |
| 2686 @override | 2171 @override |
| 2687 Token get endToken => _identifier.endToken; | 2172 Token get endToken => _identifier.endToken; |
| 2688 | 2173 |
| 2689 /** | 2174 @override |
| 2690 * Return the identifier being referenced. | |
| 2691 */ | |
| 2692 Identifier get identifier => _identifier; | 2175 Identifier get identifier => _identifier; |
| 2693 | 2176 |
| 2694 /** | 2177 @override |
| 2695 * Set the identifier being referenced to the given [identifier]. | |
| 2696 */ | |
| 2697 void set identifier(Identifier identifier) { | 2178 void set identifier(Identifier identifier) { |
| 2698 _identifier = _becomeParentOf(identifier); | 2179 _identifier = _becomeParentOf(identifier); |
| 2699 } | 2180 } |
| 2700 | 2181 |
| 2701 @override | 2182 @override |
| 2702 accept(AstVisitor visitor) => visitor.visitCommentReference(this); | 2183 accept(AstVisitor visitor) => visitor.visitCommentReference(this); |
| 2703 | 2184 |
| 2704 @override | 2185 @override |
| 2705 void visitChildren(AstVisitor visitor) { | 2186 void visitChildren(AstVisitor visitor) { |
| 2706 _safelyVisitChild(_identifier, visitor); | 2187 _safelyVisitChild(_identifier, visitor); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 * > [ScriptTag]? [LibraryDirective]? namespaceDirective* [PartDirective]* | 2237 * > [ScriptTag]? [LibraryDirective]? namespaceDirective* [PartDirective]* |
| 2757 * > | [PartOfDirective] | 2238 * > | [PartOfDirective] |
| 2758 * > | 2239 * > |
| 2759 * > namespaceDirective ::= | 2240 * > namespaceDirective ::= |
| 2760 * > [ImportDirective] | 2241 * > [ImportDirective] |
| 2761 * > | [ExportDirective] | 2242 * > | [ExportDirective] |
| 2762 * > | 2243 * > |
| 2763 * > declarations ::= | 2244 * > declarations ::= |
| 2764 * > [CompilationUnitMember]* | 2245 * > [CompilationUnitMember]* |
| 2765 */ | 2246 */ |
| 2766 class CompilationUnit extends AstNode { | 2247 class CompilationUnitImpl extends AstNodeImpl implements CompilationUnit { |
| 2767 /** | 2248 /** |
| 2768 * The first token in the token stream that was parsed to form this | 2249 * The first token in the token stream that was parsed to form this |
| 2769 * compilation unit. | 2250 * compilation unit. |
| 2770 */ | 2251 */ |
| 2771 Token beginToken; | 2252 Token beginToken; |
| 2772 | 2253 |
| 2773 /** | 2254 /** |
| 2774 * The script tag at the beginning of the compilation unit, or `null` if there | 2255 * The script tag at the beginning of the compilation unit, or `null` if there |
| 2775 * is no script tag in this compilation unit. | 2256 * is no script tag in this compilation unit. |
| 2776 */ | 2257 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2803 */ | 2284 */ |
| 2804 LineInfo lineInfo; | 2285 LineInfo lineInfo; |
| 2805 | 2286 |
| 2806 /** | 2287 /** |
| 2807 * Initialize a newly created compilation unit to have the given directives | 2288 * Initialize a newly created compilation unit to have the given directives |
| 2808 * and declarations. The [scriptTag] can be `null` if there is no script tag | 2289 * and declarations. The [scriptTag] can be `null` if there is no script tag |
| 2809 * in the compilation unit. The list of [directives] can be `null` if there | 2290 * in the compilation unit. The list of [directives] can be `null` if there |
| 2810 * are no directives in the compilation unit. The list of [declarations] can | 2291 * are no directives in the compilation unit. The list of [declarations] can |
| 2811 * be `null` if there are no declarations in the compilation unit. | 2292 * be `null` if there are no declarations in the compilation unit. |
| 2812 */ | 2293 */ |
| 2813 CompilationUnit( | 2294 CompilationUnitImpl( |
| 2814 this.beginToken, | 2295 this.beginToken, |
| 2815 ScriptTag scriptTag, | 2296 ScriptTag scriptTag, |
| 2816 List<Directive> directives, | 2297 List<Directive> directives, |
| 2817 List<CompilationUnitMember> declarations, | 2298 List<CompilationUnitMember> declarations, |
| 2818 this.endToken) { | 2299 this.endToken) { |
| 2819 _scriptTag = _becomeParentOf(scriptTag); | 2300 _scriptTag = _becomeParentOf(scriptTag); |
| 2820 _directives = new NodeList<Directive>(this, directives); | 2301 _directives = new NodeList<Directive>(this, directives); |
| 2821 _declarations = new NodeList<CompilationUnitMember>(this, declarations); | 2302 _declarations = new NodeList<CompilationUnitMember>(this, declarations); |
| 2822 } | 2303 } |
| 2823 | 2304 |
| 2824 @override | 2305 @override |
| 2825 Iterable get childEntities { | 2306 Iterable get childEntities { |
| 2826 ChildEntities result = new ChildEntities()..add(_scriptTag); | 2307 ChildEntities result = new ChildEntities()..add(_scriptTag); |
| 2827 if (_directivesAreBeforeDeclarations) { | 2308 if (_directivesAreBeforeDeclarations) { |
| 2828 result..addAll(_directives)..addAll(_declarations); | 2309 result..addAll(_directives)..addAll(_declarations); |
| 2829 } else { | 2310 } else { |
| 2830 result.addAll(sortedDirectivesAndDeclarations); | 2311 result.addAll(sortedDirectivesAndDeclarations); |
| 2831 } | 2312 } |
| 2832 return result; | 2313 return result; |
| 2833 } | 2314 } |
| 2834 | 2315 |
| 2835 /** | 2316 @override |
| 2836 * Return the declarations contained in this compilation unit. | |
| 2837 */ | |
| 2838 NodeList<CompilationUnitMember> get declarations => _declarations; | 2317 NodeList<CompilationUnitMember> get declarations => _declarations; |
| 2839 | 2318 |
| 2840 /** | 2319 @override |
| 2841 * Return the directives contained in this compilation unit. | |
| 2842 */ | |
| 2843 NodeList<Directive> get directives => _directives; | 2320 NodeList<Directive> get directives => _directives; |
| 2844 | 2321 |
| 2845 @override | 2322 @override |
| 2846 int get length { | 2323 int get length { |
| 2847 Token endToken = this.endToken; | 2324 Token endToken = this.endToken; |
| 2848 if (endToken == null) { | 2325 if (endToken == null) { |
| 2849 return 0; | 2326 return 0; |
| 2850 } | 2327 } |
| 2851 return endToken.offset + endToken.length; | 2328 return endToken.offset + endToken.length; |
| 2852 } | 2329 } |
| 2853 | 2330 |
| 2854 @override | 2331 @override |
| 2855 int get offset => 0; | 2332 int get offset => 0; |
| 2856 | 2333 |
| 2857 /** | 2334 @override |
| 2858 * Return the script tag at the beginning of the compilation unit, or `null` | |
| 2859 * if there is no script tag in this compilation unit. | |
| 2860 */ | |
| 2861 ScriptTag get scriptTag => _scriptTag; | 2335 ScriptTag get scriptTag => _scriptTag; |
| 2862 | 2336 |
| 2863 /** | 2337 @override |
| 2864 * Set the script tag at the beginning of the compilation unit to the given | |
| 2865 * [scriptTag]. | |
| 2866 */ | |
| 2867 void set scriptTag(ScriptTag scriptTag) { | 2338 void set scriptTag(ScriptTag scriptTag) { |
| 2868 _scriptTag = _becomeParentOf(scriptTag); | 2339 _scriptTag = _becomeParentOf(scriptTag); |
| 2869 } | 2340 } |
| 2870 | 2341 |
| 2871 /** | 2342 @override |
| 2872 * Return a list containing all of the directives and declarations in this | |
| 2873 * compilation unit, sorted in lexical order. | |
| 2874 */ | |
| 2875 List<AstNode> get sortedDirectivesAndDeclarations { | 2343 List<AstNode> get sortedDirectivesAndDeclarations { |
| 2876 return <AstNode>[] | 2344 return <AstNode>[] |
| 2877 ..addAll(_directives) | 2345 ..addAll(_directives) |
| 2878 ..addAll(_declarations) | 2346 ..addAll(_declarations) |
| 2879 ..sort(AstNode.LEXICAL_ORDER); | 2347 ..sort(AstNode.LEXICAL_ORDER); |
| 2880 } | 2348 } |
| 2881 | 2349 |
| 2882 /** | 2350 /** |
| 2883 * Return `true` if all of the directives are lexically before any | 2351 * Return `true` if all of the directives are lexically before any |
| 2884 * declarations. | 2352 * declarations. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2914 * unit. | 2382 * unit. |
| 2915 * | 2383 * |
| 2916 * > compilationUnitMember ::= | 2384 * > compilationUnitMember ::= |
| 2917 * > [ClassDeclaration] | 2385 * > [ClassDeclaration] |
| 2918 * > | [TypeAlias] | 2386 * > | [TypeAlias] |
| 2919 * > | [FunctionDeclaration] | 2387 * > | [FunctionDeclaration] |
| 2920 * > | [MethodDeclaration] | 2388 * > | [MethodDeclaration] |
| 2921 * > | [VariableDeclaration] | 2389 * > | [VariableDeclaration] |
| 2922 * > | [VariableDeclaration] | 2390 * > | [VariableDeclaration] |
| 2923 */ | 2391 */ |
| 2924 abstract class CompilationUnitMember extends Declaration { | 2392 abstract class CompilationUnitMemberImpl extends DeclarationImpl |
| 2393 implements CompilationUnitMember { |
| 2925 /** | 2394 /** |
| 2926 * Initialize a newly created generic compilation unit member. Either or both | 2395 * Initialize a newly created generic compilation unit member. Either or both |
| 2927 * of the [comment] and [metadata] can be `null` if the member does not have | 2396 * of the [comment] and [metadata] can be `null` if the member does not have |
| 2928 * the corresponding attribute. | 2397 * the corresponding attribute. |
| 2929 */ | 2398 */ |
| 2930 CompilationUnitMember(Comment comment, List<Annotation> metadata) | 2399 CompilationUnitMemberImpl(Comment comment, List<Annotation> metadata) |
| 2931 : super(comment, metadata); | 2400 : super(comment, metadata); |
| 2932 } | 2401 } |
| 2933 | 2402 |
| 2934 /** | 2403 /** |
| 2935 * A conditional expression. | 2404 * A conditional expression. |
| 2936 * | 2405 * |
| 2937 * > conditionalExpression ::= | 2406 * > conditionalExpression ::= |
| 2938 * > [Expression] '?' [Expression] ':' [Expression] | 2407 * > [Expression] '?' [Expression] ':' [Expression] |
| 2939 */ | 2408 */ |
| 2940 class ConditionalExpression extends Expression { | 2409 class ConditionalExpressionImpl extends ExpressionImpl |
| 2410 implements ConditionalExpression { |
| 2941 /** | 2411 /** |
| 2942 * The condition used to determine which of the expressions is executed next. | 2412 * The condition used to determine which of the expressions is executed next. |
| 2943 */ | 2413 */ |
| 2944 Expression _condition; | 2414 Expression _condition; |
| 2945 | 2415 |
| 2946 /** | 2416 /** |
| 2947 * The token used to separate the condition from the then expression. | 2417 * The token used to separate the condition from the then expression. |
| 2948 */ | 2418 */ |
| 2949 Token question; | 2419 Token question; |
| 2950 | 2420 |
| 2951 /** | 2421 /** |
| 2952 * The expression that is executed if the condition evaluates to `true`. | 2422 * The expression that is executed if the condition evaluates to `true`. |
| 2953 */ | 2423 */ |
| 2954 Expression _thenExpression; | 2424 Expression _thenExpression; |
| 2955 | 2425 |
| 2956 /** | 2426 /** |
| 2957 * The token used to separate the then expression from the else expression. | 2427 * The token used to separate the then expression from the else expression. |
| 2958 */ | 2428 */ |
| 2959 Token colon; | 2429 Token colon; |
| 2960 | 2430 |
| 2961 /** | 2431 /** |
| 2962 * The expression that is executed if the condition evaluates to `false`. | 2432 * The expression that is executed if the condition evaluates to `false`. |
| 2963 */ | 2433 */ |
| 2964 Expression _elseExpression; | 2434 Expression _elseExpression; |
| 2965 | 2435 |
| 2966 /** | 2436 /** |
| 2967 * Initialize a newly created conditional expression. | 2437 * Initialize a newly created conditional expression. |
| 2968 */ | 2438 */ |
| 2969 ConditionalExpression(Expression condition, this.question, | 2439 ConditionalExpressionImpl(Expression condition, this.question, |
| 2970 Expression thenExpression, this.colon, Expression elseExpression) { | 2440 Expression thenExpression, this.colon, Expression elseExpression) { |
| 2971 _condition = _becomeParentOf(condition); | 2441 _condition = _becomeParentOf(condition); |
| 2972 _thenExpression = _becomeParentOf(thenExpression); | 2442 _thenExpression = _becomeParentOf(thenExpression); |
| 2973 _elseExpression = _becomeParentOf(elseExpression); | 2443 _elseExpression = _becomeParentOf(elseExpression); |
| 2974 } | 2444 } |
| 2975 | 2445 |
| 2976 @override | 2446 @override |
| 2977 Token get beginToken => _condition.beginToken; | 2447 Token get beginToken => _condition.beginToken; |
| 2978 | 2448 |
| 2979 @override | 2449 @override |
| 2980 Iterable get childEntities => new ChildEntities() | 2450 Iterable get childEntities => new ChildEntities() |
| 2981 ..add(_condition) | 2451 ..add(_condition) |
| 2982 ..add(question) | 2452 ..add(question) |
| 2983 ..add(_thenExpression) | 2453 ..add(_thenExpression) |
| 2984 ..add(colon) | 2454 ..add(colon) |
| 2985 ..add(_elseExpression); | 2455 ..add(_elseExpression); |
| 2986 | 2456 |
| 2987 /** | 2457 @override |
| 2988 * Return the condition used to determine which of the expressions is executed | |
| 2989 * next. | |
| 2990 */ | |
| 2991 Expression get condition => _condition; | 2458 Expression get condition => _condition; |
| 2992 | 2459 |
| 2993 /** | 2460 @override |
| 2994 * Set the condition used to determine which of the expressions is executed | |
| 2995 * next to the given [expression]. | |
| 2996 */ | |
| 2997 void set condition(Expression expression) { | 2461 void set condition(Expression expression) { |
| 2998 _condition = _becomeParentOf(expression); | 2462 _condition = _becomeParentOf(expression); |
| 2999 } | 2463 } |
| 3000 | 2464 |
| 3001 /** | 2465 @override |
| 3002 * Return the expression that is executed if the condition evaluates to | |
| 3003 * `false`. | |
| 3004 */ | |
| 3005 Expression get elseExpression => _elseExpression; | 2466 Expression get elseExpression => _elseExpression; |
| 3006 | 2467 |
| 3007 /** | 2468 @override |
| 3008 * Set the expression that is executed if the condition evaluates to `false` | |
| 3009 * to the given [expression]. | |
| 3010 */ | |
| 3011 void set elseExpression(Expression expression) { | 2469 void set elseExpression(Expression expression) { |
| 3012 _elseExpression = _becomeParentOf(expression); | 2470 _elseExpression = _becomeParentOf(expression); |
| 3013 } | 2471 } |
| 3014 | 2472 |
| 3015 @override | 2473 @override |
| 3016 Token get endToken => _elseExpression.endToken; | 2474 Token get endToken => _elseExpression.endToken; |
| 3017 | 2475 |
| 3018 @override | 2476 @override |
| 3019 int get precedence => 3; | 2477 int get precedence => 3; |
| 3020 | 2478 |
| 3021 /** | 2479 @override |
| 3022 * Return the expression that is executed if the condition evaluates to | |
| 3023 * `true`. | |
| 3024 */ | |
| 3025 Expression get thenExpression => _thenExpression; | 2480 Expression get thenExpression => _thenExpression; |
| 3026 | 2481 |
| 3027 /** | 2482 @override |
| 3028 * Set the expression that is executed if the condition evaluates to `true` to | |
| 3029 * the given [expression]. | |
| 3030 */ | |
| 3031 void set thenExpression(Expression expression) { | 2483 void set thenExpression(Expression expression) { |
| 3032 _thenExpression = _becomeParentOf(expression); | 2484 _thenExpression = _becomeParentOf(expression); |
| 3033 } | 2485 } |
| 3034 | 2486 |
| 3035 @override | 2487 @override |
| 3036 accept(AstVisitor visitor) => visitor.visitConditionalExpression(this); | 2488 accept(AstVisitor visitor) => visitor.visitConditionalExpression(this); |
| 3037 | 2489 |
| 3038 @override | 2490 @override |
| 3039 void visitChildren(AstVisitor visitor) { | 2491 void visitChildren(AstVisitor visitor) { |
| 3040 _safelyVisitChild(_condition, visitor); | 2492 _safelyVisitChild(_condition, visitor); |
| 3041 _safelyVisitChild(_thenExpression, visitor); | 2493 _safelyVisitChild(_thenExpression, visitor); |
| 3042 _safelyVisitChild(_elseExpression, visitor); | 2494 _safelyVisitChild(_elseExpression, visitor); |
| 3043 } | 2495 } |
| 3044 } | 2496 } |
| 3045 | 2497 |
| 3046 /** | 2498 /** |
| 3047 * A configuration in either an import or export directive. | 2499 * A configuration in either an import or export directive. |
| 3048 * | 2500 * |
| 3049 * configuration ::= | 2501 * configuration ::= |
| 3050 * 'if' '(' test ')' uri | 2502 * 'if' '(' test ')' uri |
| 3051 * | 2503 * |
| 3052 * test ::= | 2504 * test ::= |
| 3053 * dottedName ('==' stringLiteral)? | 2505 * dottedName ('==' stringLiteral)? |
| 3054 * | 2506 * |
| 3055 * dottedName ::= | 2507 * dottedName ::= |
| 3056 * identifier ('.' identifier)* | 2508 * identifier ('.' identifier)* |
| 3057 */ | 2509 */ |
| 3058 class Configuration extends AstNode { | 2510 class ConfigurationImpl extends AstNodeImpl implements Configuration { |
| 3059 Token ifKeyword; | 2511 Token ifKeyword; |
| 3060 Token leftParenthesis; | 2512 Token leftParenthesis; |
| 3061 DottedName _name; | 2513 DottedName _name; |
| 3062 Token equalToken; | 2514 Token equalToken; |
| 3063 StringLiteral _value; | 2515 StringLiteral _value; |
| 3064 Token rightParenthesis; | 2516 Token rightParenthesis; |
| 3065 StringLiteral _libraryUri; | 2517 StringLiteral _libraryUri; |
| 3066 | 2518 |
| 3067 Configuration( | 2519 ConfigurationImpl( |
| 3068 this.ifKeyword, | 2520 this.ifKeyword, |
| 3069 this.leftParenthesis, | 2521 this.leftParenthesis, |
| 3070 DottedName name, | 2522 DottedName name, |
| 3071 this.equalToken, | 2523 this.equalToken, |
| 3072 StringLiteral value, | 2524 StringLiteral value, |
| 3073 this.rightParenthesis, | 2525 this.rightParenthesis, |
| 3074 StringLiteral libraryUri) { | 2526 StringLiteral libraryUri) { |
| 3075 _name = _becomeParentOf(name); | 2527 _name = _becomeParentOf(name); |
| 3076 _value = _becomeParentOf(value); | 2528 _value = _becomeParentOf(value); |
| 3077 _libraryUri = _becomeParentOf(libraryUri); | 2529 _libraryUri = _becomeParentOf(libraryUri); |
| 3078 } | 2530 } |
| 3079 | 2531 |
| 3080 @override | 2532 @override |
| 3081 Token get beginToken => ifKeyword; | 2533 Token get beginToken => ifKeyword; |
| 3082 | 2534 |
| 3083 @override | 2535 @override |
| 3084 Iterable get childEntities => new ChildEntities() | 2536 Iterable get childEntities => new ChildEntities() |
| 3085 ..add(ifKeyword) | 2537 ..add(ifKeyword) |
| 3086 ..add(leftParenthesis) | 2538 ..add(leftParenthesis) |
| 3087 ..add(_name) | 2539 ..add(_name) |
| 3088 ..add(equalToken) | 2540 ..add(equalToken) |
| 3089 ..add(_value) | 2541 ..add(_value) |
| 3090 ..add(rightParenthesis) | 2542 ..add(rightParenthesis) |
| 3091 ..add(_libraryUri); | 2543 ..add(_libraryUri); |
| 3092 | 2544 |
| 3093 @override | 2545 @override |
| 3094 Token get endToken => _libraryUri.endToken; | 2546 Token get endToken => _libraryUri.endToken; |
| 3095 | 2547 |
| 2548 @override |
| 3096 StringLiteral get libraryUri => _libraryUri; | 2549 StringLiteral get libraryUri => _libraryUri; |
| 3097 | 2550 |
| 2551 @override |
| 3098 void set libraryUri(StringLiteral libraryUri) { | 2552 void set libraryUri(StringLiteral libraryUri) { |
| 3099 _libraryUri = _becomeParentOf(libraryUri); | 2553 _libraryUri = _becomeParentOf(libraryUri); |
| 3100 } | 2554 } |
| 3101 | 2555 |
| 2556 @override |
| 3102 DottedName get name => _name; | 2557 DottedName get name => _name; |
| 3103 | 2558 |
| 2559 @override |
| 3104 void set name(DottedName name) { | 2560 void set name(DottedName name) { |
| 3105 _name = _becomeParentOf(name); | 2561 _name = _becomeParentOf(name); |
| 3106 } | 2562 } |
| 3107 | 2563 |
| 2564 @override |
| 3108 StringLiteral get value => _value; | 2565 StringLiteral get value => _value; |
| 3109 | 2566 |
| 2567 @override |
| 3110 void set value(StringLiteral value) { | 2568 void set value(StringLiteral value) { |
| 3111 _value = _becomeParentOf(value); | 2569 _value = _becomeParentOf(value); |
| 3112 } | 2570 } |
| 3113 | 2571 |
| 3114 @override | 2572 @override |
| 3115 accept(AstVisitor visitor) => visitor.visitConfiguration(this); | 2573 accept(AstVisitor visitor) => visitor.visitConfiguration(this); |
| 3116 | 2574 |
| 3117 @override | 2575 @override |
| 3118 void visitChildren(AstVisitor visitor) { | 2576 void visitChildren(AstVisitor visitor) { |
| 3119 _safelyVisitChild(_name, visitor); | 2577 _safelyVisitChild(_name, visitor); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3136 * > | 2594 * > |
| 3137 * > constructorName ::= | 2595 * > constructorName ::= |
| 3138 * > [SimpleIdentifier] ('.' [SimpleIdentifier])? | 2596 * > [SimpleIdentifier] ('.' [SimpleIdentifier])? |
| 3139 * > | 2597 * > |
| 3140 * > factoryName ::= | 2598 * > factoryName ::= |
| 3141 * > [Identifier] ('.' [SimpleIdentifier])? | 2599 * > [Identifier] ('.' [SimpleIdentifier])? |
| 3142 * > | 2600 * > |
| 3143 * > initializerList ::= | 2601 * > initializerList ::= |
| 3144 * > ':' [ConstructorInitializer] (',' [ConstructorInitializer])* | 2602 * > ':' [ConstructorInitializer] (',' [ConstructorInitializer])* |
| 3145 */ | 2603 */ |
| 3146 class ConstructorDeclaration extends ClassMember { | 2604 class ConstructorDeclarationImpl extends ClassMemberImpl |
| 2605 implements ConstructorDeclaration { |
| 3147 /** | 2606 /** |
| 3148 * The token for the 'external' keyword, or `null` if the constructor is not | 2607 * The token for the 'external' keyword, or `null` if the constructor is not |
| 3149 * external. | 2608 * external. |
| 3150 */ | 2609 */ |
| 3151 Token externalKeyword; | 2610 Token externalKeyword; |
| 3152 | 2611 |
| 3153 /** | 2612 /** |
| 3154 * The token for the 'const' keyword, or `null` if the constructor is not a | 2613 * The token for the 'const' keyword, or `null` if the constructor is not a |
| 3155 * const constructor. | 2614 * const constructor. |
| 3156 */ | 2615 */ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3224 * constructor cannot be used to create a constant. The [factoryKeyword] can | 2683 * constructor cannot be used to create a constant. The [factoryKeyword] can |
| 3225 * be `null` if the constructor is not a factory. The [period] and [name] can | 2684 * be `null` if the constructor is not a factory. The [period] and [name] can |
| 3226 * both be `null` if the constructor is not a named constructor. The | 2685 * both be `null` if the constructor is not a named constructor. The |
| 3227 * [separator] can be `null` if the constructor does not have any initializers | 2686 * [separator] can be `null` if the constructor does not have any initializers |
| 3228 * and does not redirect to a different constructor. The list of | 2687 * and does not redirect to a different constructor. The list of |
| 3229 * [initializers] can be `null` if the constructor does not have any | 2688 * [initializers] can be `null` if the constructor does not have any |
| 3230 * initializers. The [redirectedConstructor] can be `null` if the constructor | 2689 * initializers. The [redirectedConstructor] can be `null` if the constructor |
| 3231 * does not redirect to a different constructor. The [body] can be `null` if | 2690 * does not redirect to a different constructor. The [body] can be `null` if |
| 3232 * the constructor does not have a body. | 2691 * the constructor does not have a body. |
| 3233 */ | 2692 */ |
| 3234 ConstructorDeclaration( | 2693 ConstructorDeclarationImpl( |
| 3235 Comment comment, | 2694 Comment comment, |
| 3236 List<Annotation> metadata, | 2695 List<Annotation> metadata, |
| 3237 this.externalKeyword, | 2696 this.externalKeyword, |
| 3238 this.constKeyword, | 2697 this.constKeyword, |
| 3239 this.factoryKeyword, | 2698 this.factoryKeyword, |
| 3240 Identifier returnType, | 2699 Identifier returnType, |
| 3241 this.period, | 2700 this.period, |
| 3242 SimpleIdentifier name, | 2701 SimpleIdentifier name, |
| 3243 FormalParameterList parameters, | 2702 FormalParameterList parameters, |
| 3244 this.separator, | 2703 this.separator, |
| 3245 List<ConstructorInitializer> initializers, | 2704 List<ConstructorInitializer> initializers, |
| 3246 ConstructorName redirectedConstructor, | 2705 ConstructorName redirectedConstructor, |
| 3247 FunctionBody body) | 2706 FunctionBody body) |
| 3248 : super(comment, metadata) { | 2707 : super(comment, metadata) { |
| 3249 _returnType = _becomeParentOf(returnType); | 2708 _returnType = _becomeParentOf(returnType); |
| 3250 _name = _becomeParentOf(name); | 2709 _name = _becomeParentOf(name); |
| 3251 _parameters = _becomeParentOf(parameters); | 2710 _parameters = _becomeParentOf(parameters); |
| 3252 _initializers = new NodeList<ConstructorInitializer>(this, initializers); | 2711 _initializers = new NodeList<ConstructorInitializer>(this, initializers); |
| 3253 _redirectedConstructor = _becomeParentOf(redirectedConstructor); | 2712 _redirectedConstructor = _becomeParentOf(redirectedConstructor); |
| 3254 _body = _becomeParentOf(body); | 2713 _body = _becomeParentOf(body); |
| 3255 } | 2714 } |
| 3256 | 2715 |
| 3257 /** | 2716 @override |
| 3258 * Return the body of the constructor, or `null` if the constructor does not | |
| 3259 * have a body. | |
| 3260 */ | |
| 3261 FunctionBody get body => _body; | 2717 FunctionBody get body => _body; |
| 3262 | 2718 |
| 3263 /** | 2719 @override |
| 3264 * Set the body of the constructor to the given [functionBody]. | |
| 3265 */ | |
| 3266 void set body(FunctionBody functionBody) { | 2720 void set body(FunctionBody functionBody) { |
| 3267 _body = _becomeParentOf(functionBody); | 2721 _body = _becomeParentOf(functionBody); |
| 3268 } | 2722 } |
| 3269 | 2723 |
| 3270 @override | 2724 @override |
| 3271 Iterable get childEntities => super._childEntities | 2725 Iterable get childEntities => super._childEntities |
| 3272 ..add(externalKeyword) | 2726 ..add(externalKeyword) |
| 3273 ..add(constKeyword) | 2727 ..add(constKeyword) |
| 3274 ..add(factoryKeyword) | 2728 ..add(factoryKeyword) |
| 3275 ..add(_returnType) | 2729 ..add(_returnType) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3294 @override | 2748 @override |
| 3295 Token get firstTokenAfterCommentAndMetadata { | 2749 Token get firstTokenAfterCommentAndMetadata { |
| 3296 Token leftMost = | 2750 Token leftMost = |
| 3297 Token.lexicallyFirst([externalKeyword, constKeyword, factoryKeyword]); | 2751 Token.lexicallyFirst([externalKeyword, constKeyword, factoryKeyword]); |
| 3298 if (leftMost != null) { | 2752 if (leftMost != null) { |
| 3299 return leftMost; | 2753 return leftMost; |
| 3300 } | 2754 } |
| 3301 return _returnType.beginToken; | 2755 return _returnType.beginToken; |
| 3302 } | 2756 } |
| 3303 | 2757 |
| 3304 /** | 2758 @override |
| 3305 * Return the initializers associated with the constructor. | |
| 3306 */ | |
| 3307 NodeList<ConstructorInitializer> get initializers => _initializers; | 2759 NodeList<ConstructorInitializer> get initializers => _initializers; |
| 3308 | 2760 |
| 3309 /** | 2761 @override |
| 3310 * Return the name of the constructor, or `null` if the constructor being | |
| 3311 * declared is unnamed. | |
| 3312 */ | |
| 3313 SimpleIdentifier get name => _name; | 2762 SimpleIdentifier get name => _name; |
| 3314 | 2763 |
| 3315 /** | 2764 @override |
| 3316 * Set the name of the constructor to the given [identifier]. | |
| 3317 */ | |
| 3318 void set name(SimpleIdentifier identifier) { | 2765 void set name(SimpleIdentifier identifier) { |
| 3319 _name = _becomeParentOf(identifier); | 2766 _name = _becomeParentOf(identifier); |
| 3320 } | 2767 } |
| 3321 | 2768 |
| 3322 /** | 2769 @override |
| 3323 * Return the parameters associated with the constructor. | |
| 3324 */ | |
| 3325 FormalParameterList get parameters => _parameters; | 2770 FormalParameterList get parameters => _parameters; |
| 3326 | 2771 |
| 3327 /** | 2772 @override |
| 3328 * Set the parameters associated with the constructor to the given list of | |
| 3329 * [parameters]. | |
| 3330 */ | |
| 3331 void set parameters(FormalParameterList parameters) { | 2773 void set parameters(FormalParameterList parameters) { |
| 3332 _parameters = _becomeParentOf(parameters); | 2774 _parameters = _becomeParentOf(parameters); |
| 3333 } | 2775 } |
| 3334 | 2776 |
| 3335 /** | 2777 @override |
| 3336 * Return the name of the constructor to which this constructor will be | |
| 3337 * redirected, or `null` if this is not a redirecting factory constructor. | |
| 3338 */ | |
| 3339 ConstructorName get redirectedConstructor => _redirectedConstructor; | 2778 ConstructorName get redirectedConstructor => _redirectedConstructor; |
| 3340 | 2779 |
| 3341 /** | 2780 @override |
| 3342 * Set the name of the constructor to which this constructor will be | |
| 3343 * redirected to the given [redirectedConstructor] name. | |
| 3344 */ | |
| 3345 void set redirectedConstructor(ConstructorName redirectedConstructor) { | 2781 void set redirectedConstructor(ConstructorName redirectedConstructor) { |
| 3346 _redirectedConstructor = _becomeParentOf(redirectedConstructor); | 2782 _redirectedConstructor = _becomeParentOf(redirectedConstructor); |
| 3347 } | 2783 } |
| 3348 | 2784 |
| 3349 /** | 2785 @override |
| 3350 * Return the type of object being created. This can be different than the | |
| 3351 * type in which the constructor is being declared if the constructor is the | |
| 3352 * implementation of a factory constructor. | |
| 3353 */ | |
| 3354 Identifier get returnType => _returnType; | 2786 Identifier get returnType => _returnType; |
| 3355 | 2787 |
| 3356 /** | 2788 @override |
| 3357 * Set the type of object being created to the given [typeName]. | |
| 3358 */ | |
| 3359 void set returnType(Identifier typeName) { | 2789 void set returnType(Identifier typeName) { |
| 3360 _returnType = _becomeParentOf(typeName); | 2790 _returnType = _becomeParentOf(typeName); |
| 3361 } | 2791 } |
| 3362 | 2792 |
| 3363 @override | 2793 @override |
| 3364 accept(AstVisitor visitor) => visitor.visitConstructorDeclaration(this); | 2794 accept(AstVisitor visitor) => visitor.visitConstructorDeclaration(this); |
| 3365 | 2795 |
| 3366 @override | 2796 @override |
| 3367 void visitChildren(AstVisitor visitor) { | 2797 void visitChildren(AstVisitor visitor) { |
| 3368 super.visitChildren(visitor); | 2798 super.visitChildren(visitor); |
| 3369 _safelyVisitChild(_returnType, visitor); | 2799 _safelyVisitChild(_returnType, visitor); |
| 3370 _safelyVisitChild(_name, visitor); | 2800 _safelyVisitChild(_name, visitor); |
| 3371 _safelyVisitChild(_parameters, visitor); | 2801 _safelyVisitChild(_parameters, visitor); |
| 3372 _initializers.accept(visitor); | 2802 _initializers.accept(visitor); |
| 3373 _safelyVisitChild(_redirectedConstructor, visitor); | 2803 _safelyVisitChild(_redirectedConstructor, visitor); |
| 3374 _safelyVisitChild(_body, visitor); | 2804 _safelyVisitChild(_body, visitor); |
| 3375 } | 2805 } |
| 3376 } | 2806 } |
| 3377 | 2807 |
| 3378 /** | 2808 /** |
| 3379 * The initialization of a field within a constructor's initialization list. | 2809 * The initialization of a field within a constructor's initialization list. |
| 3380 * | 2810 * |
| 3381 * > fieldInitializer ::= | 2811 * > fieldInitializer ::= |
| 3382 * > ('this' '.')? [SimpleIdentifier] '=' [Expression] | 2812 * > ('this' '.')? [SimpleIdentifier] '=' [Expression] |
| 3383 */ | 2813 */ |
| 3384 class ConstructorFieldInitializer extends ConstructorInitializer { | 2814 class ConstructorFieldInitializerImpl extends ConstructorInitializerImpl |
| 2815 implements ConstructorFieldInitializer { |
| 3385 /** | 2816 /** |
| 3386 * The token for the 'this' keyword, or `null` if there is no 'this' keyword. | 2817 * The token for the 'this' keyword, or `null` if there is no 'this' keyword. |
| 3387 */ | 2818 */ |
| 3388 Token thisKeyword; | 2819 Token thisKeyword; |
| 3389 | 2820 |
| 3390 /** | 2821 /** |
| 3391 * The token for the period after the 'this' keyword, or `null` if there is no | 2822 * The token for the period after the 'this' keyword, or `null` if there is no |
| 3392 * 'this' keyword. | 2823 * 'this' keyword. |
| 3393 */ | 2824 */ |
| 3394 Token period; | 2825 Token period; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3406 /** | 2837 /** |
| 3407 * The expression computing the value to which the field will be initialized. | 2838 * The expression computing the value to which the field will be initialized. |
| 3408 */ | 2839 */ |
| 3409 Expression _expression; | 2840 Expression _expression; |
| 3410 | 2841 |
| 3411 /** | 2842 /** |
| 3412 * Initialize a newly created field initializer to initialize the field with | 2843 * Initialize a newly created field initializer to initialize the field with |
| 3413 * the given name to the value of the given expression. The [thisKeyword] and | 2844 * the given name to the value of the given expression. The [thisKeyword] and |
| 3414 * [period] can be `null` if the 'this' keyword was not specified. | 2845 * [period] can be `null` if the 'this' keyword was not specified. |
| 3415 */ | 2846 */ |
| 3416 ConstructorFieldInitializer(this.thisKeyword, this.period, | 2847 ConstructorFieldInitializerImpl(this.thisKeyword, this.period, |
| 3417 SimpleIdentifier fieldName, this.equals, Expression expression) { | 2848 SimpleIdentifier fieldName, this.equals, Expression expression) { |
| 3418 _fieldName = _becomeParentOf(fieldName); | 2849 _fieldName = _becomeParentOf(fieldName); |
| 3419 _expression = _becomeParentOf(expression); | 2850 _expression = _becomeParentOf(expression); |
| 3420 } | 2851 } |
| 3421 | 2852 |
| 3422 @override | 2853 @override |
| 3423 Token get beginToken { | 2854 Token get beginToken { |
| 3424 if (thisKeyword != null) { | 2855 if (thisKeyword != null) { |
| 3425 return thisKeyword; | 2856 return thisKeyword; |
| 3426 } | 2857 } |
| 3427 return _fieldName.beginToken; | 2858 return _fieldName.beginToken; |
| 3428 } | 2859 } |
| 3429 | 2860 |
| 3430 @override | 2861 @override |
| 3431 Iterable get childEntities => new ChildEntities() | 2862 Iterable get childEntities => new ChildEntities() |
| 3432 ..add(thisKeyword) | 2863 ..add(thisKeyword) |
| 3433 ..add(period) | 2864 ..add(period) |
| 3434 ..add(_fieldName) | 2865 ..add(_fieldName) |
| 3435 ..add(equals) | 2866 ..add(equals) |
| 3436 ..add(_expression); | 2867 ..add(_expression); |
| 3437 | 2868 |
| 3438 @override | 2869 @override |
| 3439 Token get endToken => _expression.endToken; | 2870 Token get endToken => _expression.endToken; |
| 3440 | 2871 |
| 3441 /** | 2872 @override |
| 3442 * Return the expression computing the value to which the field will be | |
| 3443 * initialized. | |
| 3444 */ | |
| 3445 Expression get expression => _expression; | 2873 Expression get expression => _expression; |
| 3446 | 2874 |
| 3447 /** | 2875 @override |
| 3448 * Set the expression computing the value to which the field will be | |
| 3449 * initialized to the given [expression]. | |
| 3450 */ | |
| 3451 void set expression(Expression expression) { | 2876 void set expression(Expression expression) { |
| 3452 _expression = _becomeParentOf(expression); | 2877 _expression = _becomeParentOf(expression); |
| 3453 } | 2878 } |
| 3454 | 2879 |
| 3455 /** | 2880 @override |
| 3456 * Return the name of the field being initialized. | |
| 3457 */ | |
| 3458 SimpleIdentifier get fieldName => _fieldName; | 2881 SimpleIdentifier get fieldName => _fieldName; |
| 3459 | 2882 |
| 3460 /** | 2883 @override |
| 3461 * Set the name of the field being initialized to the given [identifier]. | |
| 3462 */ | |
| 3463 void set fieldName(SimpleIdentifier identifier) { | 2884 void set fieldName(SimpleIdentifier identifier) { |
| 3464 _fieldName = _becomeParentOf(identifier); | 2885 _fieldName = _becomeParentOf(identifier); |
| 3465 } | 2886 } |
| 3466 | 2887 |
| 3467 @override | 2888 @override |
| 3468 accept(AstVisitor visitor) => visitor.visitConstructorFieldInitializer(this); | 2889 accept(AstVisitor visitor) => visitor.visitConstructorFieldInitializer(this); |
| 3469 | 2890 |
| 3470 @override | 2891 @override |
| 3471 void visitChildren(AstVisitor visitor) { | 2892 void visitChildren(AstVisitor visitor) { |
| 3472 _safelyVisitChild(_fieldName, visitor); | 2893 _safelyVisitChild(_fieldName, visitor); |
| 3473 _safelyVisitChild(_expression, visitor); | 2894 _safelyVisitChild(_expression, visitor); |
| 3474 } | 2895 } |
| 3475 } | 2896 } |
| 3476 | 2897 |
| 3477 /** | 2898 /** |
| 3478 * A node that can occur in the initializer list of a constructor declaration. | 2899 * A node that can occur in the initializer list of a constructor declaration. |
| 3479 * | 2900 * |
| 3480 * > constructorInitializer ::= | 2901 * > constructorInitializer ::= |
| 3481 * > [SuperConstructorInvocation] | 2902 * > [SuperConstructorInvocation] |
| 3482 * > | [ConstructorFieldInitializer] | 2903 * > | [ConstructorFieldInitializer] |
| 3483 * > | [RedirectingConstructorInvocation] | 2904 * > | [RedirectingConstructorInvocation] |
| 3484 */ | 2905 */ |
| 3485 abstract class ConstructorInitializer extends AstNode {} | 2906 abstract class ConstructorInitializerImpl extends AstNodeImpl |
| 2907 implements ConstructorInitializer {} |
| 3486 | 2908 |
| 3487 /** | 2909 /** |
| 3488 * The name of the constructor. | 2910 * The name of the constructor. |
| 3489 * | 2911 * |
| 3490 * > constructorName ::= | 2912 * > constructorName ::= |
| 3491 * > type ('.' identifier)? | 2913 * > type ('.' identifier)? |
| 3492 */ | 2914 */ |
| 3493 class ConstructorName extends AstNode { | 2915 class ConstructorNameImpl extends AstNodeImpl implements ConstructorName { |
| 3494 /** | 2916 /** |
| 3495 * The name of the type defining the constructor. | 2917 * The name of the type defining the constructor. |
| 3496 */ | 2918 */ |
| 3497 TypeName _type; | 2919 TypeName _type; |
| 3498 | 2920 |
| 3499 /** | 2921 /** |
| 3500 * The token for the period before the constructor name, or `null` if the | 2922 * The token for the period before the constructor name, or `null` if the |
| 3501 * specified constructor is the unnamed constructor. | 2923 * specified constructor is the unnamed constructor. |
| 3502 */ | 2924 */ |
| 3503 Token period; | 2925 Token period; |
| 3504 | 2926 |
| 3505 /** | 2927 /** |
| 3506 * The name of the constructor, or `null` if the specified constructor is the | 2928 * The name of the constructor, or `null` if the specified constructor is the |
| 3507 * unnamed constructor. | 2929 * unnamed constructor. |
| 3508 */ | 2930 */ |
| 3509 SimpleIdentifier _name; | 2931 SimpleIdentifier _name; |
| 3510 | 2932 |
| 3511 /** | 2933 /** |
| 3512 * The element associated with this constructor name based on static type | 2934 * The element associated with this constructor name based on static type |
| 3513 * information, or `null` if the AST structure has not been resolved or if | 2935 * information, or `null` if the AST structure has not been resolved or if |
| 3514 * this constructor name could not be resolved. | 2936 * this constructor name could not be resolved. |
| 3515 */ | 2937 */ |
| 3516 ConstructorElement staticElement; | 2938 ConstructorElement staticElement; |
| 3517 | 2939 |
| 3518 /** | 2940 /** |
| 3519 * Initialize a newly created constructor name. The [period] and [name] can be | 2941 * Initialize a newly created constructor name. The [period] and [name] can be |
| 3520 * `null` if the constructor being named is the unnamed constructor. | 2942 * `null` if the constructor being named is the unnamed constructor. |
| 3521 */ | 2943 */ |
| 3522 ConstructorName(TypeName type, this.period, SimpleIdentifier name) { | 2944 ConstructorNameImpl(TypeName type, this.period, SimpleIdentifier name) { |
| 3523 _type = _becomeParentOf(type); | 2945 _type = _becomeParentOf(type); |
| 3524 _name = _becomeParentOf(name); | 2946 _name = _becomeParentOf(name); |
| 3525 } | 2947 } |
| 3526 | 2948 |
| 3527 @override | 2949 @override |
| 3528 Token get beginToken => _type.beginToken; | 2950 Token get beginToken => _type.beginToken; |
| 3529 | 2951 |
| 3530 @override | 2952 @override |
| 3531 Iterable get childEntities => | 2953 Iterable get childEntities => |
| 3532 new ChildEntities()..add(_type)..add(period)..add(_name); | 2954 new ChildEntities()..add(_type)..add(period)..add(_name); |
| 3533 | 2955 |
| 3534 @override | 2956 @override |
| 3535 Token get endToken { | 2957 Token get endToken { |
| 3536 if (_name != null) { | 2958 if (_name != null) { |
| 3537 return _name.endToken; | 2959 return _name.endToken; |
| 3538 } | 2960 } |
| 3539 return _type.endToken; | 2961 return _type.endToken; |
| 3540 } | 2962 } |
| 3541 | 2963 |
| 3542 /** | 2964 @override |
| 3543 * Return the name of the constructor, or `null` if the specified constructor | |
| 3544 * is the unnamed constructor. | |
| 3545 */ | |
| 3546 SimpleIdentifier get name => _name; | 2965 SimpleIdentifier get name => _name; |
| 3547 | 2966 |
| 3548 /** | 2967 @override |
| 3549 * Set the name of the constructor to the given [name]. | |
| 3550 */ | |
| 3551 void set name(SimpleIdentifier name) { | 2968 void set name(SimpleIdentifier name) { |
| 3552 _name = _becomeParentOf(name); | 2969 _name = _becomeParentOf(name); |
| 3553 } | 2970 } |
| 3554 | 2971 |
| 3555 /** | 2972 @override |
| 3556 * Return the name of the type defining the constructor. | |
| 3557 */ | |
| 3558 TypeName get type => _type; | 2973 TypeName get type => _type; |
| 3559 | 2974 |
| 3560 /** | 2975 @override |
| 3561 * Set the name of the type defining the constructor to the given [type] name. | |
| 3562 */ | |
| 3563 void set type(TypeName type) { | 2976 void set type(TypeName type) { |
| 3564 _type = _becomeParentOf(type); | 2977 _type = _becomeParentOf(type); |
| 3565 } | 2978 } |
| 3566 | 2979 |
| 3567 @override | 2980 @override |
| 3568 accept(AstVisitor visitor) => visitor.visitConstructorName(this); | 2981 accept(AstVisitor visitor) => visitor.visitConstructorName(this); |
| 3569 | 2982 |
| 3570 @override | 2983 @override |
| 3571 void visitChildren(AstVisitor visitor) { | 2984 void visitChildren(AstVisitor visitor) { |
| 3572 _safelyVisitChild(_type, visitor); | 2985 _safelyVisitChild(_type, visitor); |
| 3573 _safelyVisitChild(_name, visitor); | 2986 _safelyVisitChild(_name, visitor); |
| 3574 } | 2987 } |
| 3575 } | 2988 } |
| 3576 | 2989 |
| 3577 /** | 2990 /** |
| 3578 * A continue statement. | 2991 * A continue statement. |
| 3579 * | 2992 * |
| 3580 * > continueStatement ::= | 2993 * > continueStatement ::= |
| 3581 * > 'continue' [SimpleIdentifier]? ';' | 2994 * > 'continue' [SimpleIdentifier]? ';' |
| 3582 */ | 2995 */ |
| 3583 class ContinueStatement extends Statement { | 2996 class ContinueStatementImpl extends StatementImpl implements ContinueStatement { |
| 3584 /** | 2997 /** |
| 3585 * The token representing the 'continue' keyword. | 2998 * The token representing the 'continue' keyword. |
| 3586 */ | 2999 */ |
| 3587 Token continueKeyword; | 3000 Token continueKeyword; |
| 3588 | 3001 |
| 3589 /** | 3002 /** |
| 3590 * The label associated with the statement, or `null` if there is no label. | 3003 * The label associated with the statement, or `null` if there is no label. |
| 3591 */ | 3004 */ |
| 3592 SimpleIdentifier _label; | 3005 SimpleIdentifier _label; |
| 3593 | 3006 |
| 3594 /** | 3007 /** |
| 3595 * The semicolon terminating the statement. | 3008 * The semicolon terminating the statement. |
| 3596 */ | 3009 */ |
| 3597 Token semicolon; | 3010 Token semicolon; |
| 3598 | 3011 |
| 3599 /** | 3012 /** |
| 3600 * The AstNode which this continue statement is continuing to. This will be | 3013 * The AstNode which this continue statement is continuing to. This will be |
| 3601 * either a Statement (in the case of continuing a loop) or a SwitchMember | 3014 * either a Statement (in the case of continuing a loop) or a SwitchMember |
| 3602 * (in the case of continuing from one switch case to another). Null if the | 3015 * (in the case of continuing from one switch case to another). Null if the |
| 3603 * AST has not yet been resolved or if the target could not be resolved. | 3016 * AST has not yet been resolved or if the target could not be resolved. |
| 3604 * Note that if the source code has errors, the target may be invalid (e.g. | 3017 * Note that if the source code has errors, the target may be invalid (e.g. |
| 3605 * the target may be in an enclosing function). | 3018 * the target may be in an enclosing function). |
| 3606 */ | 3019 */ |
| 3607 AstNode target; | 3020 AstNode target; |
| 3608 | 3021 |
| 3609 /** | 3022 /** |
| 3610 * Initialize a newly created continue statement. The [label] can be `null` if | 3023 * Initialize a newly created continue statement. The [label] can be `null` if |
| 3611 * there is no label associated with the statement. | 3024 * there is no label associated with the statement. |
| 3612 */ | 3025 */ |
| 3613 ContinueStatement( | 3026 ContinueStatementImpl( |
| 3614 this.continueKeyword, SimpleIdentifier label, this.semicolon) { | 3027 this.continueKeyword, SimpleIdentifier label, this.semicolon) { |
| 3615 _label = _becomeParentOf(label); | 3028 _label = _becomeParentOf(label); |
| 3616 } | 3029 } |
| 3617 | 3030 |
| 3618 @override | 3031 @override |
| 3619 Token get beginToken => continueKeyword; | 3032 Token get beginToken => continueKeyword; |
| 3620 | 3033 |
| 3621 @override | 3034 @override |
| 3622 Iterable get childEntities => | 3035 Iterable get childEntities => |
| 3623 new ChildEntities()..add(continueKeyword)..add(_label)..add(semicolon); | 3036 new ChildEntities()..add(continueKeyword)..add(_label)..add(semicolon); |
| 3624 | 3037 |
| 3625 @override | 3038 @override |
| 3626 Token get endToken => semicolon; | 3039 Token get endToken => semicolon; |
| 3627 | 3040 |
| 3628 /** | 3041 @override |
| 3629 * Return the label associated with the statement, or `null` if there is no | |
| 3630 * label. | |
| 3631 */ | |
| 3632 SimpleIdentifier get label => _label; | 3042 SimpleIdentifier get label => _label; |
| 3633 | 3043 |
| 3634 /** | 3044 @override |
| 3635 * Set the label associated with the statement to the given [identifier]. | |
| 3636 */ | |
| 3637 void set label(SimpleIdentifier identifier) { | 3045 void set label(SimpleIdentifier identifier) { |
| 3638 _label = _becomeParentOf(identifier); | 3046 _label = _becomeParentOf(identifier); |
| 3639 } | 3047 } |
| 3640 | 3048 |
| 3641 @override | 3049 @override |
| 3642 accept(AstVisitor visitor) => visitor.visitContinueStatement(this); | 3050 accept(AstVisitor visitor) => visitor.visitContinueStatement(this); |
| 3643 | 3051 |
| 3644 @override | 3052 @override |
| 3645 void visitChildren(AstVisitor visitor) { | 3053 void visitChildren(AstVisitor visitor) { |
| 3646 _safelyVisitChild(_label, visitor); | 3054 _safelyVisitChild(_label, visitor); |
| 3647 } | 3055 } |
| 3648 } | 3056 } |
| 3649 | 3057 |
| 3650 /** | 3058 /** |
| 3651 * A node that represents the declaration of one or more names. Each declared | 3059 * A node that represents the declaration of one or more names. Each declared |
| 3652 * name is visible within a name scope. | 3060 * name is visible within a name scope. |
| 3653 */ | 3061 */ |
| 3654 abstract class Declaration extends AnnotatedNode { | 3062 abstract class DeclarationImpl extends AnnotatedNodeImpl |
| 3063 implements Declaration { |
| 3655 /** | 3064 /** |
| 3656 * Initialize a newly created declaration. Either or both of the [comment] and | 3065 * Initialize a newly created declaration. Either or both of the [comment] and |
| 3657 * [metadata] can be `null` if the declaration does not have the corresponding | 3066 * [metadata] can be `null` if the declaration does not have the corresponding |
| 3658 * attribute. | 3067 * attribute. |
| 3659 */ | 3068 */ |
| 3660 Declaration(Comment comment, List<Annotation> metadata) | 3069 DeclarationImpl(Comment comment, List<Annotation> metadata) |
| 3661 : super(comment, metadata); | 3070 : super(comment, metadata); |
| 3662 | |
| 3663 /** | |
| 3664 * Return the element associated with this declaration, or `null` if either | |
| 3665 * this node corresponds to a list of declarations or if the AST structure has | |
| 3666 * not been resolved. | |
| 3667 */ | |
| 3668 Element get element; | |
| 3669 } | 3071 } |
| 3670 | 3072 |
| 3671 /** | 3073 /** |
| 3672 * The declaration of a single identifier. | 3074 * The declaration of a single identifier. |
| 3673 * | 3075 * |
| 3674 * > declaredIdentifier ::= | 3076 * > declaredIdentifier ::= |
| 3675 * > [Annotation] finalConstVarOrType [SimpleIdentifier] | 3077 * > [Annotation] finalConstVarOrType [SimpleIdentifier] |
| 3676 */ | 3078 */ |
| 3677 class DeclaredIdentifier extends Declaration { | 3079 class DeclaredIdentifierImpl extends DeclarationImpl |
| 3080 implements DeclaredIdentifier { |
| 3678 /** | 3081 /** |
| 3679 * The token representing either the 'final', 'const' or 'var' keyword, or | 3082 * The token representing either the 'final', 'const' or 'var' keyword, or |
| 3680 * `null` if no keyword was used. | 3083 * `null` if no keyword was used. |
| 3681 */ | 3084 */ |
| 3682 Token keyword; | 3085 Token keyword; |
| 3683 | 3086 |
| 3684 /** | 3087 /** |
| 3685 * The name of the declared type of the parameter, or `null` if the parameter | 3088 * The name of the declared type of the parameter, or `null` if the parameter |
| 3686 * does not have a declared type. | 3089 * does not have a declared type. |
| 3687 */ | 3090 */ |
| 3688 TypeName _type; | 3091 TypeName _type; |
| 3689 | 3092 |
| 3690 /** | 3093 /** |
| 3691 * The name of the variable being declared. | 3094 * The name of the variable being declared. |
| 3692 */ | 3095 */ |
| 3693 SimpleIdentifier _identifier; | 3096 SimpleIdentifier _identifier; |
| 3694 | 3097 |
| 3695 /** | 3098 /** |
| 3696 * Initialize a newly created formal parameter. Either or both of the | 3099 * Initialize a newly created formal parameter. Either or both of the |
| 3697 * [comment] and [metadata] can be `null` if the declaration does not have the | 3100 * [comment] and [metadata] can be `null` if the declaration does not have the |
| 3698 * corresponding attribute. The [keyword] can be `null` if a type name is | 3101 * corresponding attribute. The [keyword] can be `null` if a type name is |
| 3699 * given. The [type] must be `null` if the keyword is 'var'. | 3102 * given. The [type] must be `null` if the keyword is 'var'. |
| 3700 */ | 3103 */ |
| 3701 DeclaredIdentifier(Comment comment, List<Annotation> metadata, this.keyword, | 3104 DeclaredIdentifierImpl(Comment comment, List<Annotation> metadata, |
| 3702 TypeName type, SimpleIdentifier identifier) | 3105 this.keyword, TypeName type, SimpleIdentifier identifier) |
| 3703 : super(comment, metadata) { | 3106 : super(comment, metadata) { |
| 3704 _type = _becomeParentOf(type); | 3107 _type = _becomeParentOf(type); |
| 3705 _identifier = _becomeParentOf(identifier); | 3108 _identifier = _becomeParentOf(identifier); |
| 3706 } | 3109 } |
| 3707 | 3110 |
| 3708 @override | 3111 @override |
| 3709 Iterable get childEntities => | 3112 Iterable get childEntities => |
| 3710 super._childEntities..add(keyword)..add(_type)..add(_identifier); | 3113 super._childEntities..add(keyword)..add(_type)..add(_identifier); |
| 3711 | 3114 |
| 3712 @override | 3115 @override |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3723 @override | 3126 @override |
| 3724 Token get firstTokenAfterCommentAndMetadata { | 3127 Token get firstTokenAfterCommentAndMetadata { |
| 3725 if (keyword != null) { | 3128 if (keyword != null) { |
| 3726 return keyword; | 3129 return keyword; |
| 3727 } else if (_type != null) { | 3130 } else if (_type != null) { |
| 3728 return _type.beginToken; | 3131 return _type.beginToken; |
| 3729 } | 3132 } |
| 3730 return _identifier.beginToken; | 3133 return _identifier.beginToken; |
| 3731 } | 3134 } |
| 3732 | 3135 |
| 3733 /** | 3136 @override |
| 3734 * Return the name of the variable being declared. | |
| 3735 */ | |
| 3736 SimpleIdentifier get identifier => _identifier; | 3137 SimpleIdentifier get identifier => _identifier; |
| 3737 | 3138 |
| 3738 /** | 3139 @override |
| 3739 * Set the name of the variable being declared to the given [identifier]. | |
| 3740 */ | |
| 3741 void set identifier(SimpleIdentifier identifier) { | 3140 void set identifier(SimpleIdentifier identifier) { |
| 3742 _identifier = _becomeParentOf(identifier); | 3141 _identifier = _becomeParentOf(identifier); |
| 3743 } | 3142 } |
| 3744 | 3143 |
| 3745 /** | 3144 @override |
| 3746 * Return `true` if this variable was declared with the 'const' modifier. | |
| 3747 */ | |
| 3748 bool get isConst => | 3145 bool get isConst => |
| 3749 (keyword is KeywordToken) && | 3146 (keyword is KeywordToken) && |
| 3750 (keyword as KeywordToken).keyword == Keyword.CONST; | 3147 (keyword as KeywordToken).keyword == Keyword.CONST; |
| 3751 | 3148 |
| 3752 /** | 3149 @override |
| 3753 * Return `true` if this variable was declared with the 'final' modifier. | |
| 3754 * Variables that are declared with the 'const' modifier will return `false` | |
| 3755 * even though they are implicitly final. | |
| 3756 */ | |
| 3757 bool get isFinal => | 3150 bool get isFinal => |
| 3758 (keyword is KeywordToken) && | 3151 (keyword is KeywordToken) && |
| 3759 (keyword as KeywordToken).keyword == Keyword.FINAL; | 3152 (keyword as KeywordToken).keyword == Keyword.FINAL; |
| 3760 | 3153 |
| 3761 /** | 3154 @override |
| 3762 * Return the name of the declared type of the parameter, or `null` if the | |
| 3763 * parameter does not have a declared type. | |
| 3764 */ | |
| 3765 TypeName get type => _type; | 3155 TypeName get type => _type; |
| 3766 | 3156 |
| 3767 /** | 3157 @override |
| 3768 * Set the name of the declared type of the parameter to the given [typeName]. | |
| 3769 */ | |
| 3770 void set type(TypeName typeName) { | 3158 void set type(TypeName typeName) { |
| 3771 _type = _becomeParentOf(typeName); | 3159 _type = _becomeParentOf(typeName); |
| 3772 } | 3160 } |
| 3773 | 3161 |
| 3774 @override | 3162 @override |
| 3775 accept(AstVisitor visitor) => visitor.visitDeclaredIdentifier(this); | 3163 accept(AstVisitor visitor) => visitor.visitDeclaredIdentifier(this); |
| 3776 | 3164 |
| 3777 @override | 3165 @override |
| 3778 void visitChildren(AstVisitor visitor) { | 3166 void visitChildren(AstVisitor visitor) { |
| 3779 super.visitChildren(visitor); | 3167 super.visitChildren(visitor); |
| 3780 _safelyVisitChild(_type, visitor); | 3168 _safelyVisitChild(_type, visitor); |
| 3781 _safelyVisitChild(_identifier, visitor); | 3169 _safelyVisitChild(_identifier, visitor); |
| 3782 } | 3170 } |
| 3783 } | 3171 } |
| 3784 | 3172 |
| 3785 /** | 3173 /** |
| 3786 * A formal parameter with a default value. There are two kinds of parameters | 3174 * A formal parameter with a default value. There are two kinds of parameters |
| 3787 * that are both represented by this class: named formal parameters and | 3175 * that are both represented by this class: named formal parameters and |
| 3788 * positional formal parameters. | 3176 * positional formal parameters. |
| 3789 * | 3177 * |
| 3790 * > defaultFormalParameter ::= | 3178 * > defaultFormalParameter ::= |
| 3791 * > [NormalFormalParameter] ('=' [Expression])? | 3179 * > [NormalFormalParameter] ('=' [Expression])? |
| 3792 * > | 3180 * > |
| 3793 * > defaultNamedParameter ::= | 3181 * > defaultNamedParameter ::= |
| 3794 * > [NormalFormalParameter] (':' [Expression])? | 3182 * > [NormalFormalParameter] (':' [Expression])? |
| 3795 */ | 3183 */ |
| 3796 class DefaultFormalParameter extends FormalParameter { | 3184 class DefaultFormalParameterImpl extends FormalParameterImpl |
| 3185 implements DefaultFormalParameter { |
| 3797 /** | 3186 /** |
| 3798 * The formal parameter with which the default value is associated. | 3187 * The formal parameter with which the default value is associated. |
| 3799 */ | 3188 */ |
| 3800 NormalFormalParameter _parameter; | 3189 NormalFormalParameter _parameter; |
| 3801 | 3190 |
| 3802 /** | 3191 /** |
| 3803 * The kind of this parameter. | 3192 * The kind of this parameter. |
| 3804 */ | 3193 */ |
| 3805 ParameterKind kind; | 3194 ParameterKind kind; |
| 3806 | 3195 |
| 3807 /** | 3196 /** |
| 3808 * The token separating the parameter from the default value, or `null` if | 3197 * The token separating the parameter from the default value, or `null` if |
| 3809 * there is no default value. | 3198 * there is no default value. |
| 3810 */ | 3199 */ |
| 3811 Token separator; | 3200 Token separator; |
| 3812 | 3201 |
| 3813 /** | 3202 /** |
| 3814 * The expression computing the default value for the parameter, or `null` if | 3203 * The expression computing the default value for the parameter, or `null` if |
| 3815 * there is no default value. | 3204 * there is no default value. |
| 3816 */ | 3205 */ |
| 3817 Expression _defaultValue; | 3206 Expression _defaultValue; |
| 3818 | 3207 |
| 3819 /** | 3208 /** |
| 3820 * Initialize a newly created default formal parameter. The [separator] and | 3209 * Initialize a newly created default formal parameter. The [separator] and |
| 3821 * [defaultValue] can be `null` if there is no default value. | 3210 * [defaultValue] can be `null` if there is no default value. |
| 3822 */ | 3211 */ |
| 3823 DefaultFormalParameter(NormalFormalParameter parameter, this.kind, | 3212 DefaultFormalParameterImpl(NormalFormalParameter parameter, this.kind, |
| 3824 this.separator, Expression defaultValue) { | 3213 this.separator, Expression defaultValue) { |
| 3825 _parameter = _becomeParentOf(parameter); | 3214 _parameter = _becomeParentOf(parameter); |
| 3826 _defaultValue = _becomeParentOf(defaultValue); | 3215 _defaultValue = _becomeParentOf(defaultValue); |
| 3827 } | 3216 } |
| 3828 | 3217 |
| 3829 @override | 3218 @override |
| 3830 Token get beginToken => _parameter.beginToken; | 3219 Token get beginToken => _parameter.beginToken; |
| 3831 | 3220 |
| 3832 @override | 3221 @override |
| 3833 Iterable get childEntities => | 3222 Iterable get childEntities => |
| 3834 new ChildEntities()..add(_parameter)..add(separator)..add(_defaultValue); | 3223 new ChildEntities()..add(_parameter)..add(separator)..add(_defaultValue); |
| 3835 | 3224 |
| 3836 /** | 3225 @override |
| 3837 * Return the expression computing the default value for the parameter, or | |
| 3838 * `null` if there is no default value. | |
| 3839 */ | |
| 3840 Expression get defaultValue => _defaultValue; | 3226 Expression get defaultValue => _defaultValue; |
| 3841 | 3227 |
| 3842 /** | 3228 @override |
| 3843 * Set the expression computing the default value for the parameter to the | |
| 3844 * given [expression]. | |
| 3845 */ | |
| 3846 void set defaultValue(Expression expression) { | 3229 void set defaultValue(Expression expression) { |
| 3847 _defaultValue = _becomeParentOf(expression); | 3230 _defaultValue = _becomeParentOf(expression); |
| 3848 } | 3231 } |
| 3849 | 3232 |
| 3850 @override | 3233 @override |
| 3851 Token get endToken { | 3234 Token get endToken { |
| 3852 if (_defaultValue != null) { | 3235 if (_defaultValue != null) { |
| 3853 return _defaultValue.endToken; | 3236 return _defaultValue.endToken; |
| 3854 } | 3237 } |
| 3855 return _parameter.endToken; | 3238 return _parameter.endToken; |
| 3856 } | 3239 } |
| 3857 | 3240 |
| 3858 @override | 3241 @override |
| 3859 SimpleIdentifier get identifier => _parameter.identifier; | 3242 SimpleIdentifier get identifier => _parameter.identifier; |
| 3860 | 3243 |
| 3861 @override | 3244 @override |
| 3862 bool get isConst => _parameter != null && _parameter.isConst; | 3245 bool get isConst => _parameter != null && _parameter.isConst; |
| 3863 | 3246 |
| 3864 @override | 3247 @override |
| 3865 bool get isFinal => _parameter != null && _parameter.isFinal; | 3248 bool get isFinal => _parameter != null && _parameter.isFinal; |
| 3866 | 3249 |
| 3867 @override | 3250 @override |
| 3868 NodeList<Annotation> get metadata => _parameter.metadata; | 3251 NodeList<Annotation> get metadata => _parameter.metadata; |
| 3869 | 3252 |
| 3870 /** | 3253 @override |
| 3871 * Return the formal parameter with which the default value is associated. | |
| 3872 */ | |
| 3873 NormalFormalParameter get parameter => _parameter; | 3254 NormalFormalParameter get parameter => _parameter; |
| 3874 | 3255 |
| 3875 /** | 3256 @override |
| 3876 * Set the formal parameter with which the default value is associated to the | |
| 3877 * given [formalParameter]. | |
| 3878 */ | |
| 3879 void set parameter(NormalFormalParameter formalParameter) { | 3257 void set parameter(NormalFormalParameter formalParameter) { |
| 3880 _parameter = _becomeParentOf(formalParameter); | 3258 _parameter = _becomeParentOf(formalParameter); |
| 3881 } | 3259 } |
| 3882 | 3260 |
| 3883 @override | 3261 @override |
| 3884 accept(AstVisitor visitor) => visitor.visitDefaultFormalParameter(this); | 3262 accept(AstVisitor visitor) => visitor.visitDefaultFormalParameter(this); |
| 3885 | 3263 |
| 3886 @override | 3264 @override |
| 3887 void visitChildren(AstVisitor visitor) { | 3265 void visitChildren(AstVisitor visitor) { |
| 3888 _safelyVisitChild(_parameter, visitor); | 3266 _safelyVisitChild(_parameter, visitor); |
| 3889 _safelyVisitChild(_defaultValue, visitor); | 3267 _safelyVisitChild(_defaultValue, visitor); |
| 3890 } | 3268 } |
| 3891 } | 3269 } |
| 3892 | 3270 |
| 3893 /** | 3271 /** |
| 3894 * A node that represents a directive. | 3272 * A node that represents a directive. |
| 3895 * | 3273 * |
| 3896 * > directive ::= | 3274 * > directive ::= |
| 3897 * > [ExportDirective] | 3275 * > [ExportDirective] |
| 3898 * > | [ImportDirective] | 3276 * > | [ImportDirective] |
| 3899 * > | [LibraryDirective] | 3277 * > | [LibraryDirective] |
| 3900 * > | [PartDirective] | 3278 * > | [PartDirective] |
| 3901 * > | [PartOfDirective] | 3279 * > | [PartOfDirective] |
| 3902 */ | 3280 */ |
| 3903 abstract class Directive extends AnnotatedNode { | 3281 abstract class DirectiveImpl extends AnnotatedNodeImpl implements Directive { |
| 3904 /** | 3282 /** |
| 3905 * The element associated with this directive, or `null` if the AST structure | 3283 * The element associated with this directive, or `null` if the AST structure |
| 3906 * has not been resolved or if this directive could not be resolved. | 3284 * has not been resolved or if this directive could not be resolved. |
| 3907 */ | 3285 */ |
| 3908 Element element; | 3286 Element element; |
| 3909 | 3287 |
| 3910 /** | 3288 /** |
| 3911 * Initialize a newly create directive. Either or both of the [comment] and | 3289 * Initialize a newly create directive. Either or both of the [comment] and |
| 3912 * [metadata] can be `null` if the directive does not have the corresponding | 3290 * [metadata] can be `null` if the directive does not have the corresponding |
| 3913 * attribute. | 3291 * attribute. |
| 3914 */ | 3292 */ |
| 3915 Directive(Comment comment, List<Annotation> metadata) | 3293 DirectiveImpl(Comment comment, List<Annotation> metadata) |
| 3916 : super(comment, metadata); | 3294 : super(comment, metadata); |
| 3917 | |
| 3918 /** | |
| 3919 * Return the token representing the keyword that introduces this directive | |
| 3920 * ('import', 'export', 'library' or 'part'). | |
| 3921 */ | |
| 3922 Token get keyword; | |
| 3923 } | 3295 } |
| 3924 | 3296 |
| 3925 /** | 3297 /** |
| 3926 * A do statement. | 3298 * A do statement. |
| 3927 * | 3299 * |
| 3928 * > doStatement ::= | 3300 * > doStatement ::= |
| 3929 * > 'do' [Statement] 'while' '(' [Expression] ')' ';' | 3301 * > 'do' [Statement] 'while' '(' [Expression] ')' ';' |
| 3930 */ | 3302 */ |
| 3931 class DoStatement extends Statement { | 3303 class DoStatementImpl extends StatementImpl implements DoStatement { |
| 3932 /** | 3304 /** |
| 3933 * The token representing the 'do' keyword. | 3305 * The token representing the 'do' keyword. |
| 3934 */ | 3306 */ |
| 3935 Token doKeyword; | 3307 Token doKeyword; |
| 3936 | 3308 |
| 3937 /** | 3309 /** |
| 3938 * The body of the loop. | 3310 * The body of the loop. |
| 3939 */ | 3311 */ |
| 3940 Statement _body; | 3312 Statement _body; |
| 3941 | 3313 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3960 Token rightParenthesis; | 3332 Token rightParenthesis; |
| 3961 | 3333 |
| 3962 /** | 3334 /** |
| 3963 * The semicolon terminating the statement. | 3335 * The semicolon terminating the statement. |
| 3964 */ | 3336 */ |
| 3965 Token semicolon; | 3337 Token semicolon; |
| 3966 | 3338 |
| 3967 /** | 3339 /** |
| 3968 * Initialize a newly created do loop. | 3340 * Initialize a newly created do loop. |
| 3969 */ | 3341 */ |
| 3970 DoStatement( | 3342 DoStatementImpl( |
| 3971 this.doKeyword, | 3343 this.doKeyword, |
| 3972 Statement body, | 3344 Statement body, |
| 3973 this.whileKeyword, | 3345 this.whileKeyword, |
| 3974 this.leftParenthesis, | 3346 this.leftParenthesis, |
| 3975 Expression condition, | 3347 Expression condition, |
| 3976 this.rightParenthesis, | 3348 this.rightParenthesis, |
| 3977 this.semicolon) { | 3349 this.semicolon) { |
| 3978 _body = _becomeParentOf(body); | 3350 _body = _becomeParentOf(body); |
| 3979 _condition = _becomeParentOf(condition); | 3351 _condition = _becomeParentOf(condition); |
| 3980 } | 3352 } |
| 3981 | 3353 |
| 3982 @override | 3354 @override |
| 3983 Token get beginToken => doKeyword; | 3355 Token get beginToken => doKeyword; |
| 3984 | 3356 |
| 3985 /** | 3357 @override |
| 3986 * Return the body of the loop. | |
| 3987 */ | |
| 3988 Statement get body => _body; | 3358 Statement get body => _body; |
| 3989 | 3359 |
| 3990 /** | 3360 @override |
| 3991 * Set the body of the loop to the given [statement]. | |
| 3992 */ | |
| 3993 void set body(Statement statement) { | 3361 void set body(Statement statement) { |
| 3994 _body = _becomeParentOf(statement); | 3362 _body = _becomeParentOf(statement); |
| 3995 } | 3363 } |
| 3996 | 3364 |
| 3997 @override | 3365 @override |
| 3998 Iterable get childEntities => new ChildEntities() | 3366 Iterable get childEntities => new ChildEntities() |
| 3999 ..add(doKeyword) | 3367 ..add(doKeyword) |
| 4000 ..add(_body) | 3368 ..add(_body) |
| 4001 ..add(whileKeyword) | 3369 ..add(whileKeyword) |
| 4002 ..add(leftParenthesis) | 3370 ..add(leftParenthesis) |
| 4003 ..add(_condition) | 3371 ..add(_condition) |
| 4004 ..add(rightParenthesis) | 3372 ..add(rightParenthesis) |
| 4005 ..add(semicolon); | 3373 ..add(semicolon); |
| 4006 | 3374 |
| 4007 /** | 3375 @override |
| 4008 * Return the condition that determines when the loop will terminate. | |
| 4009 */ | |
| 4010 Expression get condition => _condition; | 3376 Expression get condition => _condition; |
| 4011 | 3377 |
| 4012 /** | 3378 @override |
| 4013 * Set the condition that determines when the loop will terminate to the given | |
| 4014 * [expression]. | |
| 4015 */ | |
| 4016 void set condition(Expression expression) { | 3379 void set condition(Expression expression) { |
| 4017 _condition = _becomeParentOf(expression); | 3380 _condition = _becomeParentOf(expression); |
| 4018 } | 3381 } |
| 4019 | 3382 |
| 4020 @override | 3383 @override |
| 4021 Token get endToken => semicolon; | 3384 Token get endToken => semicolon; |
| 4022 | 3385 |
| 4023 @override | 3386 @override |
| 4024 accept(AstVisitor visitor) => visitor.visitDoStatement(this); | 3387 accept(AstVisitor visitor) => visitor.visitDoStatement(this); |
| 4025 | 3388 |
| 4026 @override | 3389 @override |
| 4027 void visitChildren(AstVisitor visitor) { | 3390 void visitChildren(AstVisitor visitor) { |
| 4028 _safelyVisitChild(_body, visitor); | 3391 _safelyVisitChild(_body, visitor); |
| 4029 _safelyVisitChild(_condition, visitor); | 3392 _safelyVisitChild(_condition, visitor); |
| 4030 } | 3393 } |
| 4031 } | 3394 } |
| 4032 | 3395 |
| 4033 /** | 3396 /** |
| 4034 * A dotted name, used in a configuration within an import or export directive. | 3397 * A dotted name, used in a configuration within an import or export directive. |
| 4035 * | 3398 * |
| 4036 * > dottedName ::= | 3399 * > dottedName ::= |
| 4037 * > [SimpleIdentifier] ('.' [SimpleIdentifier])* | 3400 * > [SimpleIdentifier] ('.' [SimpleIdentifier])* |
| 4038 */ | 3401 */ |
| 4039 class DottedName extends AstNode { | 3402 class DottedNameImpl extends AstNodeImpl implements DottedName { |
| 4040 /** | 3403 /** |
| 4041 * The components of the identifier. | 3404 * The components of the identifier. |
| 4042 */ | 3405 */ |
| 4043 NodeList<SimpleIdentifier> _components; | 3406 NodeList<SimpleIdentifier> _components; |
| 4044 | 3407 |
| 4045 /** | 3408 /** |
| 4046 * Initialize a newly created dotted name. | 3409 * Initialize a newly created dotted name. |
| 4047 */ | 3410 */ |
| 4048 DottedName(List<SimpleIdentifier> components) { | 3411 DottedNameImpl(List<SimpleIdentifier> components) { |
| 4049 _components = new NodeList<SimpleIdentifier>(this, components); | 3412 _components = new NodeList<SimpleIdentifier>(this, components); |
| 4050 } | 3413 } |
| 4051 | 3414 |
| 4052 @override | 3415 @override |
| 4053 Token get beginToken => _components.beginToken; | 3416 Token get beginToken => _components.beginToken; |
| 4054 | 3417 |
| 4055 @override | 3418 @override |
| 4056 // TODO(paulberry): add "." tokens. | 3419 // TODO(paulberry): add "." tokens. |
| 4057 Iterable get childEntities => new ChildEntities()..addAll(_components); | 3420 Iterable get childEntities => new ChildEntities()..addAll(_components); |
| 4058 | 3421 |
| 4059 /** | 3422 @override |
| 4060 * Return the components of the identifier. | |
| 4061 */ | |
| 4062 NodeList<SimpleIdentifier> get components => _components; | 3423 NodeList<SimpleIdentifier> get components => _components; |
| 4063 | 3424 |
| 4064 @override | 3425 @override |
| 4065 Token get endToken => _components.endToken; | 3426 Token get endToken => _components.endToken; |
| 4066 | 3427 |
| 4067 @override | 3428 @override |
| 4068 accept(AstVisitor visitor) => visitor.visitDottedName(this); | 3429 accept(AstVisitor visitor) => visitor.visitDottedName(this); |
| 4069 | 3430 |
| 4070 @override | 3431 @override |
| 4071 void visitChildren(AstVisitor visitor) { | 3432 void visitChildren(AstVisitor visitor) { |
| 4072 _components.accept(visitor); | 3433 _components.accept(visitor); |
| 4073 } | 3434 } |
| 4074 } | 3435 } |
| 4075 | 3436 |
| 4076 /** | 3437 /** |
| 4077 * A floating point literal expression. | 3438 * A floating point literal expression. |
| 4078 * | 3439 * |
| 4079 * > doubleLiteral ::= | 3440 * > doubleLiteral ::= |
| 4080 * > decimalDigit+ ('.' decimalDigit*)? exponent? | 3441 * > decimalDigit+ ('.' decimalDigit*)? exponent? |
| 4081 * > | '.' decimalDigit+ exponent? | 3442 * > | '.' decimalDigit+ exponent? |
| 4082 * > | 3443 * > |
| 4083 * > exponent ::= | 3444 * > exponent ::= |
| 4084 * > ('e' | 'E') ('+' | '-')? decimalDigit+ | 3445 * > ('e' | 'E') ('+' | '-')? decimalDigit+ |
| 4085 */ | 3446 */ |
| 4086 class DoubleLiteral extends Literal { | 3447 class DoubleLiteralImpl extends LiteralImpl implements DoubleLiteral { |
| 4087 /** | 3448 /** |
| 4088 * The token representing the literal. | 3449 * The token representing the literal. |
| 4089 */ | 3450 */ |
| 4090 Token literal; | 3451 Token literal; |
| 4091 | 3452 |
| 4092 /** | 3453 /** |
| 4093 * The value of the literal. | 3454 * The value of the literal. |
| 4094 */ | 3455 */ |
| 4095 double value; | 3456 double value; |
| 4096 | 3457 |
| 4097 /** | 3458 /** |
| 4098 * Initialize a newly created floating point literal. | 3459 * Initialize a newly created floating point literal. |
| 4099 */ | 3460 */ |
| 4100 DoubleLiteral(this.literal, this.value); | 3461 DoubleLiteralImpl(this.literal, this.value); |
| 4101 | 3462 |
| 4102 @override | 3463 @override |
| 4103 Token get beginToken => literal; | 3464 Token get beginToken => literal; |
| 4104 | 3465 |
| 4105 @override | 3466 @override |
| 4106 Iterable get childEntities => new ChildEntities()..add(literal); | 3467 Iterable get childEntities => new ChildEntities()..add(literal); |
| 4107 | 3468 |
| 4108 @override | 3469 @override |
| 4109 Token get endToken => literal; | 3470 Token get endToken => literal; |
| 4110 | 3471 |
| 4111 @override | 3472 @override |
| 4112 accept(AstVisitor visitor) => visitor.visitDoubleLiteral(this); | 3473 accept(AstVisitor visitor) => visitor.visitDoubleLiteral(this); |
| 4113 | 3474 |
| 4114 @override | 3475 @override |
| 4115 void visitChildren(AstVisitor visitor) { | 3476 void visitChildren(AstVisitor visitor) { |
| 4116 // There are no children to visit. | 3477 // There are no children to visit. |
| 4117 } | 3478 } |
| 4118 } | 3479 } |
| 4119 | 3480 |
| 4120 /** | 3481 /** |
| 4121 * An empty function body, which can only appear in constructors or abstract | 3482 * An empty function body, which can only appear in constructors or abstract |
| 4122 * methods. | 3483 * methods. |
| 4123 * | 3484 * |
| 4124 * > emptyFunctionBody ::= | 3485 * > emptyFunctionBody ::= |
| 4125 * > ';' | 3486 * > ';' |
| 4126 */ | 3487 */ |
| 4127 class EmptyFunctionBody extends FunctionBody { | 3488 class EmptyFunctionBodyImpl extends FunctionBodyImpl |
| 3489 implements EmptyFunctionBody { |
| 4128 /** | 3490 /** |
| 4129 * The token representing the semicolon that marks the end of the function | 3491 * The token representing the semicolon that marks the end of the function |
| 4130 * body. | 3492 * body. |
| 4131 */ | 3493 */ |
| 4132 Token semicolon; | 3494 Token semicolon; |
| 4133 | 3495 |
| 4134 /** | 3496 /** |
| 4135 * Initialize a newly created function body. | 3497 * Initialize a newly created function body. |
| 4136 */ | 3498 */ |
| 4137 EmptyFunctionBody(this.semicolon); | 3499 EmptyFunctionBodyImpl(this.semicolon); |
| 4138 | 3500 |
| 4139 @override | 3501 @override |
| 4140 Token get beginToken => semicolon; | 3502 Token get beginToken => semicolon; |
| 4141 | 3503 |
| 4142 @override | 3504 @override |
| 4143 Iterable get childEntities => new ChildEntities()..add(semicolon); | 3505 Iterable get childEntities => new ChildEntities()..add(semicolon); |
| 4144 | 3506 |
| 4145 @override | 3507 @override |
| 4146 Token get endToken => semicolon; | 3508 Token get endToken => semicolon; |
| 4147 | 3509 |
| 4148 @override | 3510 @override |
| 4149 accept(AstVisitor visitor) => visitor.visitEmptyFunctionBody(this); | 3511 accept(AstVisitor visitor) => visitor.visitEmptyFunctionBody(this); |
| 4150 | 3512 |
| 4151 @override | 3513 @override |
| 4152 void visitChildren(AstVisitor visitor) { | 3514 void visitChildren(AstVisitor visitor) { |
| 4153 // Empty function bodies have no children. | 3515 // Empty function bodies have no children. |
| 4154 } | 3516 } |
| 4155 } | 3517 } |
| 4156 | 3518 |
| 4157 /** | 3519 /** |
| 4158 * An empty statement. | 3520 * An empty statement. |
| 4159 * | 3521 * |
| 4160 * > emptyStatement ::= | 3522 * > emptyStatement ::= |
| 4161 * > ';' | 3523 * > ';' |
| 4162 */ | 3524 */ |
| 4163 class EmptyStatement extends Statement { | 3525 class EmptyStatementImpl extends StatementImpl implements EmptyStatement { |
| 4164 /** | 3526 /** |
| 4165 * The semicolon terminating the statement. | 3527 * The semicolon terminating the statement. |
| 4166 */ | 3528 */ |
| 4167 Token semicolon; | 3529 Token semicolon; |
| 4168 | 3530 |
| 4169 /** | 3531 /** |
| 4170 * Initialize a newly created empty statement. | 3532 * Initialize a newly created empty statement. |
| 4171 */ | 3533 */ |
| 4172 EmptyStatement(this.semicolon); | 3534 EmptyStatementImpl(this.semicolon); |
| 4173 | 3535 |
| 4174 @override | 3536 @override |
| 4175 Token get beginToken => semicolon; | 3537 Token get beginToken => semicolon; |
| 4176 | 3538 |
| 4177 @override | 3539 @override |
| 4178 Iterable get childEntities => new ChildEntities()..add(semicolon); | 3540 Iterable get childEntities => new ChildEntities()..add(semicolon); |
| 4179 | 3541 |
| 4180 @override | 3542 @override |
| 4181 Token get endToken => semicolon; | 3543 Token get endToken => semicolon; |
| 4182 | 3544 |
| 4183 @override | 3545 @override |
| 4184 accept(AstVisitor visitor) => visitor.visitEmptyStatement(this); | 3546 accept(AstVisitor visitor) => visitor.visitEmptyStatement(this); |
| 4185 | 3547 |
| 4186 @override | 3548 @override |
| 4187 void visitChildren(AstVisitor visitor) { | 3549 void visitChildren(AstVisitor visitor) { |
| 4188 // There are no children to visit. | 3550 // There are no children to visit. |
| 4189 } | 3551 } |
| 4190 } | 3552 } |
| 4191 | 3553 |
| 4192 /** | 3554 /** |
| 4193 * The declaration of an enum constant. | 3555 * The declaration of an enum constant. |
| 4194 */ | 3556 */ |
| 4195 class EnumConstantDeclaration extends Declaration { | 3557 class EnumConstantDeclarationImpl extends DeclarationImpl |
| 3558 implements EnumConstantDeclaration { |
| 4196 /** | 3559 /** |
| 4197 * The name of the constant. | 3560 * The name of the constant. |
| 4198 */ | 3561 */ |
| 4199 SimpleIdentifier _name; | 3562 SimpleIdentifier _name; |
| 4200 | 3563 |
| 4201 /** | 3564 /** |
| 4202 * Initialize a newly created enum constant declaration. Either or both of the | 3565 * Initialize a newly created enum constant declaration. Either or both of the |
| 4203 * [comment] and [metadata] can be `null` if the constant does not have the | 3566 * [comment] and [metadata] can be `null` if the constant does not have the |
| 4204 * corresponding attribute. (Technically, enum constants cannot have metadata, | 3567 * corresponding attribute. (Technically, enum constants cannot have metadata, |
| 4205 * but we allow it for consistency.) | 3568 * but we allow it for consistency.) |
| 4206 */ | 3569 */ |
| 4207 EnumConstantDeclaration( | 3570 EnumConstantDeclarationImpl( |
| 4208 Comment comment, List<Annotation> metadata, SimpleIdentifier name) | 3571 Comment comment, List<Annotation> metadata, SimpleIdentifier name) |
| 4209 : super(comment, metadata) { | 3572 : super(comment, metadata) { |
| 4210 _name = _becomeParentOf(name); | 3573 _name = _becomeParentOf(name); |
| 4211 } | 3574 } |
| 4212 | 3575 |
| 4213 @override | 3576 @override |
| 4214 Iterable get childEntities => super._childEntities..add(_name); | 3577 Iterable get childEntities => super._childEntities..add(_name); |
| 4215 | 3578 |
| 4216 @override | 3579 @override |
| 4217 FieldElement get element => | 3580 FieldElement get element => |
| 4218 _name == null ? null : (_name.staticElement as FieldElement); | 3581 _name == null ? null : (_name.staticElement as FieldElement); |
| 4219 | 3582 |
| 4220 @override | 3583 @override |
| 4221 Token get endToken => _name.endToken; | 3584 Token get endToken => _name.endToken; |
| 4222 | 3585 |
| 4223 @override | 3586 @override |
| 4224 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; | 3587 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; |
| 4225 | 3588 |
| 4226 /** | 3589 @override |
| 4227 * Return the name of the constant. | |
| 4228 */ | |
| 4229 SimpleIdentifier get name => _name; | 3590 SimpleIdentifier get name => _name; |
| 4230 | 3591 |
| 4231 /** | 3592 @override |
| 4232 * Set the name of the constant to the given [name]. | |
| 4233 */ | |
| 4234 void set name(SimpleIdentifier name) { | 3593 void set name(SimpleIdentifier name) { |
| 4235 _name = _becomeParentOf(name); | 3594 _name = _becomeParentOf(name); |
| 4236 } | 3595 } |
| 4237 | 3596 |
| 4238 @override | 3597 @override |
| 4239 accept(AstVisitor visitor) => visitor.visitEnumConstantDeclaration(this); | 3598 accept(AstVisitor visitor) => visitor.visitEnumConstantDeclaration(this); |
| 4240 | 3599 |
| 4241 @override | 3600 @override |
| 4242 void visitChildren(AstVisitor visitor) { | 3601 void visitChildren(AstVisitor visitor) { |
| 4243 super.visitChildren(visitor); | 3602 super.visitChildren(visitor); |
| 4244 _safelyVisitChild(_name, visitor); | 3603 _safelyVisitChild(_name, visitor); |
| 4245 } | 3604 } |
| 4246 } | 3605 } |
| 4247 | 3606 |
| 4248 /** | 3607 /** |
| 4249 * The declaration of an enumeration. | 3608 * The declaration of an enumeration. |
| 4250 * | 3609 * |
| 4251 * > enumType ::= | 3610 * > enumType ::= |
| 4252 * > metadata 'enum' [SimpleIdentifier] '{' [SimpleIdentifier] (',' [SimpleI
dentifier])* (',')? '}' | 3611 * > metadata 'enum' [SimpleIdentifier] '{' [SimpleIdentifier] (',' [SimpleI
dentifier])* (',')? '}' |
| 4253 */ | 3612 */ |
| 4254 class EnumDeclaration extends NamedCompilationUnitMember { | 3613 class EnumDeclarationImpl extends NamedCompilationUnitMemberImpl |
| 3614 implements EnumDeclaration { |
| 4255 /** | 3615 /** |
| 4256 * The 'enum' keyword. | 3616 * The 'enum' keyword. |
| 4257 */ | 3617 */ |
| 4258 Token enumKeyword; | 3618 Token enumKeyword; |
| 4259 | 3619 |
| 4260 /** | 3620 /** |
| 4261 * The left curly bracket. | 3621 * The left curly bracket. |
| 4262 */ | 3622 */ |
| 4263 Token leftBracket; | 3623 Token leftBracket; |
| 4264 | 3624 |
| 4265 /** | 3625 /** |
| 4266 * The enumeration constants being declared. | 3626 * The enumeration constants being declared. |
| 4267 */ | 3627 */ |
| 4268 NodeList<EnumConstantDeclaration> _constants; | 3628 NodeList<EnumConstantDeclaration> _constants; |
| 4269 | 3629 |
| 4270 /** | 3630 /** |
| 4271 * The right curly bracket. | 3631 * The right curly bracket. |
| 4272 */ | 3632 */ |
| 4273 Token rightBracket; | 3633 Token rightBracket; |
| 4274 | 3634 |
| 4275 /** | 3635 /** |
| 4276 * Initialize a newly created enumeration declaration. Either or both of the | 3636 * Initialize a newly created enumeration declaration. Either or both of the |
| 4277 * [comment] and [metadata] can be `null` if the declaration does not have the | 3637 * [comment] and [metadata] can be `null` if the declaration does not have the |
| 4278 * corresponding attribute. The list of [constants] must contain at least one | 3638 * corresponding attribute. The list of [constants] must contain at least one |
| 4279 * value. | 3639 * value. |
| 4280 */ | 3640 */ |
| 4281 EnumDeclaration( | 3641 EnumDeclarationImpl( |
| 4282 Comment comment, | 3642 Comment comment, |
| 4283 List<Annotation> metadata, | 3643 List<Annotation> metadata, |
| 4284 this.enumKeyword, | 3644 this.enumKeyword, |
| 4285 SimpleIdentifier name, | 3645 SimpleIdentifier name, |
| 4286 this.leftBracket, | 3646 this.leftBracket, |
| 4287 List<EnumConstantDeclaration> constants, | 3647 List<EnumConstantDeclaration> constants, |
| 4288 this.rightBracket) | 3648 this.rightBracket) |
| 4289 : super(comment, metadata, name) { | 3649 : super(comment, metadata, name) { |
| 4290 _constants = new NodeList<EnumConstantDeclaration>(this, constants); | 3650 _constants = new NodeList<EnumConstantDeclaration>(this, constants); |
| 4291 } | 3651 } |
| 4292 | 3652 |
| 4293 @override | 3653 @override |
| 4294 // TODO(brianwilkerson) Add commas? | 3654 // TODO(brianwilkerson) Add commas? |
| 4295 Iterable get childEntities => super._childEntities | 3655 Iterable get childEntities => super._childEntities |
| 4296 ..add(enumKeyword) | 3656 ..add(enumKeyword) |
| 4297 ..add(_name) | 3657 ..add(_name) |
| 4298 ..add(leftBracket) | 3658 ..add(leftBracket) |
| 4299 ..addAll(_constants) | 3659 ..addAll(_constants) |
| 4300 ..add(rightBracket); | 3660 ..add(rightBracket); |
| 4301 | 3661 |
| 4302 /** | 3662 @override |
| 4303 * Return the enumeration constants being declared. | |
| 4304 */ | |
| 4305 NodeList<EnumConstantDeclaration> get constants => _constants; | 3663 NodeList<EnumConstantDeclaration> get constants => _constants; |
| 4306 | 3664 |
| 4307 @override | 3665 @override |
| 4308 ClassElement get element => | 3666 ClassElement get element => |
| 4309 _name != null ? (_name.staticElement as ClassElement) : null; | 3667 _name != null ? (_name.staticElement as ClassElement) : null; |
| 4310 | 3668 |
| 4311 @override | 3669 @override |
| 4312 Token get endToken => rightBracket; | 3670 Token get endToken => rightBracket; |
| 4313 | 3671 |
| 4314 @override | 3672 @override |
| 4315 Token get firstTokenAfterCommentAndMetadata => enumKeyword; | 3673 Token get firstTokenAfterCommentAndMetadata => enumKeyword; |
| 4316 | 3674 |
| 4317 @override | 3675 @override |
| 4318 accept(AstVisitor visitor) => visitor.visitEnumDeclaration(this); | 3676 accept(AstVisitor visitor) => visitor.visitEnumDeclaration(this); |
| 4319 | 3677 |
| 4320 @override | 3678 @override |
| 4321 void visitChildren(AstVisitor visitor) { | 3679 void visitChildren(AstVisitor visitor) { |
| 4322 super.visitChildren(visitor); | 3680 super.visitChildren(visitor); |
| 4323 _safelyVisitChild(_name, visitor); | 3681 _safelyVisitChild(_name, visitor); |
| 4324 _constants.accept(visitor); | 3682 _constants.accept(visitor); |
| 4325 } | 3683 } |
| 4326 } | 3684 } |
| 4327 | 3685 |
| 4328 /** | 3686 /** |
| 4329 * Ephemeral identifiers are created as needed to mimic the presence of an empty | 3687 * Ephemeral identifiers are created as needed to mimic the presence of an empty |
| 4330 * identifier. | 3688 * identifier. |
| 4331 */ | 3689 */ |
| 4332 class EphemeralIdentifier extends SimpleIdentifier { | 3690 class EphemeralIdentifier extends SimpleIdentifierImpl { |
| 4333 EphemeralIdentifier(AstNode parent, int location) | 3691 EphemeralIdentifier(AstNode parent, int location) |
| 4334 : super(new StringToken(TokenType.IDENTIFIER, "", location)) { | 3692 : super(new StringToken(TokenType.IDENTIFIER, "", location)) { |
| 4335 parent._becomeParentOf(this); | 3693 (parent as AstNodeImpl)._becomeParentOf(this); |
| 4336 } | 3694 } |
| 4337 } | 3695 } |
| 4338 | 3696 |
| 4339 /** | 3697 /** |
| 4340 * An export directive. | 3698 * An export directive. |
| 4341 * | 3699 * |
| 4342 * > exportDirective ::= | 3700 * > exportDirective ::= |
| 4343 * > [Annotation] 'export' [StringLiteral] [Combinator]* ';' | 3701 * > [Annotation] 'export' [StringLiteral] [Combinator]* ';' |
| 4344 */ | 3702 */ |
| 4345 class ExportDirective extends NamespaceDirective { | 3703 class ExportDirectiveImpl extends NamespaceDirectiveImpl |
| 3704 implements ExportDirective { |
| 4346 /** | 3705 /** |
| 4347 * Initialize a newly created export directive. Either or both of the | 3706 * Initialize a newly created export directive. Either or both of the |
| 4348 * [comment] and [metadata] can be `null` if the directive does not have the | 3707 * [comment] and [metadata] can be `null` if the directive does not have the |
| 4349 * corresponding attribute. The list of [combinators] can be `null` if there | 3708 * corresponding attribute. The list of [combinators] can be `null` if there |
| 4350 * are no combinators. | 3709 * are no combinators. |
| 4351 */ | 3710 */ |
| 4352 ExportDirective( | 3711 ExportDirectiveImpl( |
| 4353 Comment comment, | 3712 Comment comment, |
| 4354 List<Annotation> metadata, | 3713 List<Annotation> metadata, |
| 4355 Token keyword, | 3714 Token keyword, |
| 4356 StringLiteral libraryUri, | 3715 StringLiteral libraryUri, |
| 4357 List<Configuration> configurations, | 3716 List<Configuration> configurations, |
| 4358 List<Combinator> combinators, | 3717 List<Combinator> combinators, |
| 4359 Token semicolon) | 3718 Token semicolon) |
| 4360 : super(comment, metadata, keyword, libraryUri, configurations, | 3719 : super(comment, metadata, keyword, libraryUri, configurations, |
| 4361 combinators, semicolon); | 3720 combinators, semicolon); |
| 4362 | 3721 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4381 accept(AstVisitor visitor) => visitor.visitExportDirective(this); | 3740 accept(AstVisitor visitor) => visitor.visitExportDirective(this); |
| 4382 | 3741 |
| 4383 @override | 3742 @override |
| 4384 void visitChildren(AstVisitor visitor) { | 3743 void visitChildren(AstVisitor visitor) { |
| 4385 super.visitChildren(visitor); | 3744 super.visitChildren(visitor); |
| 4386 combinators.accept(visitor); | 3745 combinators.accept(visitor); |
| 4387 } | 3746 } |
| 4388 } | 3747 } |
| 4389 | 3748 |
| 4390 /** | 3749 /** |
| 4391 * A node that represents an expression. | |
| 4392 * | |
| 4393 * > expression ::= | |
| 4394 * > [AssignmentExpression] | |
| 4395 * > | [ConditionalExpression] cascadeSection* | |
| 4396 * > | [ThrowExpression] | |
| 4397 */ | |
| 4398 abstract class Expression extends AstNode { | |
| 4399 /** | |
| 4400 * An empty list of expressions. | |
| 4401 */ | |
| 4402 static const List<Expression> EMPTY_LIST = const <Expression>[]; | |
| 4403 | |
| 4404 /** | |
| 4405 * The static type of this expression, or `null` if the AST structure has not | |
| 4406 * been resolved. | |
| 4407 */ | |
| 4408 DartType staticType; | |
| 4409 | |
| 4410 /** | |
| 4411 * The propagated type of this expression, or `null` if type propagation has | |
| 4412 * not been performed on the AST structure. | |
| 4413 */ | |
| 4414 DartType propagatedType; | |
| 4415 | |
| 4416 /** | |
| 4417 * Return the best parameter element information available for this | |
| 4418 * expression. If type propagation was able to find a better parameter element | |
| 4419 * than static analysis, that type will be returned. Otherwise, the result of | |
| 4420 * static analysis will be returned. | |
| 4421 */ | |
| 4422 ParameterElement get bestParameterElement { | |
| 4423 ParameterElement propagatedElement = propagatedParameterElement; | |
| 4424 if (propagatedElement != null) { | |
| 4425 return propagatedElement; | |
| 4426 } | |
| 4427 return staticParameterElement; | |
| 4428 } | |
| 4429 | |
| 4430 /** | |
| 4431 * Return the best type information available for this expression. If type | |
| 4432 * propagation was able to find a better type than static analysis, that type | |
| 4433 * will be returned. Otherwise, the result of static analysis will be | |
| 4434 * returned. If no type analysis has been performed, then the type 'dynamic' | |
| 4435 * will be returned. | |
| 4436 */ | |
| 4437 DartType get bestType { | |
| 4438 if (propagatedType != null) { | |
| 4439 return propagatedType; | |
| 4440 } else if (staticType != null) { | |
| 4441 return staticType; | |
| 4442 } | |
| 4443 return DynamicTypeImpl.instance; | |
| 4444 } | |
| 4445 | |
| 4446 /** | |
| 4447 * Return `true` if this expression is syntactically valid for the LHS of an | |
| 4448 * [AssignmentExpression]. | |
| 4449 */ | |
| 4450 bool get isAssignable => false; | |
| 4451 | |
| 4452 /** | |
| 4453 * Return the precedence of this expression. The precedence is a positive | |
| 4454 * integer value that defines how the source code is parsed into an AST. For | |
| 4455 * example `a * b + c` is parsed as `(a * b) + c` because the precedence of | |
| 4456 * `*` is greater than the precedence of `+`. | |
| 4457 * | |
| 4458 * Clients should not assume that returned values will stay the same, they | |
| 4459 * might change as result of specification change. Only relative order should | |
| 4460 * be used. | |
| 4461 */ | |
| 4462 int get precedence; | |
| 4463 | |
| 4464 /** | |
| 4465 * If this expression is an argument to an invocation, and the AST structure | |
| 4466 * has been resolved, and the function being invoked is known based on | |
| 4467 * propagated type information, and this expression corresponds to one of the | |
| 4468 * parameters of the function being invoked, then return the parameter element | |
| 4469 * representing the parameter to which the value of this expression will be | |
| 4470 * bound. Otherwise, return `null`. | |
| 4471 */ | |
| 4472 ParameterElement get propagatedParameterElement { | |
| 4473 AstNode parent = this.parent; | |
| 4474 if (parent is ArgumentList) { | |
| 4475 return parent._getPropagatedParameterElementFor(this); | |
| 4476 } else if (parent is IndexExpression) { | |
| 4477 IndexExpression indexExpression = parent; | |
| 4478 if (identical(indexExpression.index, this)) { | |
| 4479 return indexExpression._propagatedParameterElementForIndex; | |
| 4480 } | |
| 4481 } else if (parent is BinaryExpression) { | |
| 4482 BinaryExpression binaryExpression = parent; | |
| 4483 if (identical(binaryExpression.rightOperand, this)) { | |
| 4484 return binaryExpression._propagatedParameterElementForRightOperand; | |
| 4485 } | |
| 4486 } else if (parent is AssignmentExpression) { | |
| 4487 AssignmentExpression assignmentExpression = parent; | |
| 4488 if (identical(assignmentExpression.rightHandSide, this)) { | |
| 4489 return assignmentExpression._propagatedParameterElementForRightHandSide; | |
| 4490 } | |
| 4491 } else if (parent is PrefixExpression) { | |
| 4492 return parent._propagatedParameterElementForOperand; | |
| 4493 } else if (parent is PostfixExpression) { | |
| 4494 return parent._propagatedParameterElementForOperand; | |
| 4495 } | |
| 4496 return null; | |
| 4497 } | |
| 4498 | |
| 4499 /** | |
| 4500 * If this expression is an argument to an invocation, and the AST structure | |
| 4501 * has been resolved, and the function being invoked is known based on static | |
| 4502 * type information, and this expression corresponds to one of the parameters | |
| 4503 * of the function being invoked, then return the parameter element | |
| 4504 * representing the parameter to which the value of this expression will be | |
| 4505 * bound. Otherwise, return `null`. | |
| 4506 */ | |
| 4507 ParameterElement get staticParameterElement { | |
| 4508 AstNode parent = this.parent; | |
| 4509 if (parent is ArgumentList) { | |
| 4510 return parent._getStaticParameterElementFor(this); | |
| 4511 } else if (parent is IndexExpression) { | |
| 4512 IndexExpression indexExpression = parent; | |
| 4513 if (identical(indexExpression.index, this)) { | |
| 4514 return indexExpression._staticParameterElementForIndex; | |
| 4515 } | |
| 4516 } else if (parent is BinaryExpression) { | |
| 4517 BinaryExpression binaryExpression = parent; | |
| 4518 if (identical(binaryExpression.rightOperand, this)) { | |
| 4519 return binaryExpression._staticParameterElementForRightOperand; | |
| 4520 } | |
| 4521 } else if (parent is AssignmentExpression) { | |
| 4522 AssignmentExpression assignmentExpression = parent; | |
| 4523 if (identical(assignmentExpression.rightHandSide, this)) { | |
| 4524 return assignmentExpression._staticParameterElementForRightHandSide; | |
| 4525 } | |
| 4526 } else if (parent is PrefixExpression) { | |
| 4527 return parent._staticParameterElementForOperand; | |
| 4528 } else if (parent is PostfixExpression) { | |
| 4529 return parent._staticParameterElementForOperand; | |
| 4530 } | |
| 4531 return null; | |
| 4532 } | |
| 4533 } | |
| 4534 | |
| 4535 /** | |
| 4536 * A function body consisting of a single expression. | 3750 * A function body consisting of a single expression. |
| 4537 * | 3751 * |
| 4538 * > expressionFunctionBody ::= | 3752 * > expressionFunctionBody ::= |
| 4539 * > 'async'? '=>' [Expression] ';' | 3753 * > 'async'? '=>' [Expression] ';' |
| 4540 */ | 3754 */ |
| 4541 class ExpressionFunctionBody extends FunctionBody { | 3755 class ExpressionFunctionBodyImpl extends FunctionBodyImpl |
| 3756 implements ExpressionFunctionBody { |
| 4542 /** | 3757 /** |
| 4543 * The token representing the 'async' keyword, or `null` if there is no such | 3758 * The token representing the 'async' keyword, or `null` if there is no such |
| 4544 * keyword. | 3759 * keyword. |
| 4545 */ | 3760 */ |
| 4546 Token keyword; | 3761 Token keyword; |
| 4547 | 3762 |
| 4548 /** | 3763 /** |
| 4549 * The token introducing the expression that represents the body of the | 3764 * The token introducing the expression that represents the body of the |
| 4550 * function. | 3765 * function. |
| 4551 */ | 3766 */ |
| 4552 Token functionDefinition; | 3767 Token functionDefinition; |
| 4553 | 3768 |
| 4554 /** | 3769 /** |
| 4555 * The expression representing the body of the function. | 3770 * The expression representing the body of the function. |
| 4556 */ | 3771 */ |
| 4557 Expression _expression; | 3772 Expression _expression; |
| 4558 | 3773 |
| 4559 /** | 3774 /** |
| 4560 * The semicolon terminating the statement. | 3775 * The semicolon terminating the statement. |
| 4561 */ | 3776 */ |
| 4562 Token semicolon; | 3777 Token semicolon; |
| 4563 | 3778 |
| 4564 /** | 3779 /** |
| 4565 * Initialize a newly created function body consisting of a block of | 3780 * Initialize a newly created function body consisting of a block of |
| 4566 * statements. The [keyword] can be `null` if the function body is not an | 3781 * statements. The [keyword] can be `null` if the function body is not an |
| 4567 * async function body. | 3782 * async function body. |
| 4568 */ | 3783 */ |
| 4569 ExpressionFunctionBody(this.keyword, this.functionDefinition, | 3784 ExpressionFunctionBodyImpl(this.keyword, this.functionDefinition, |
| 4570 Expression expression, this.semicolon) { | 3785 Expression expression, this.semicolon) { |
| 4571 _expression = _becomeParentOf(expression); | 3786 _expression = _becomeParentOf(expression); |
| 4572 } | 3787 } |
| 4573 | 3788 |
| 4574 @override | 3789 @override |
| 4575 Token get beginToken { | 3790 Token get beginToken { |
| 4576 if (keyword != null) { | 3791 if (keyword != null) { |
| 4577 return keyword; | 3792 return keyword; |
| 4578 } | 3793 } |
| 4579 return functionDefinition; | 3794 return functionDefinition; |
| 4580 } | 3795 } |
| 4581 | 3796 |
| 4582 @override | 3797 @override |
| 4583 Iterable get childEntities => new ChildEntities() | 3798 Iterable get childEntities => new ChildEntities() |
| 4584 ..add(keyword) | 3799 ..add(keyword) |
| 4585 ..add(functionDefinition) | 3800 ..add(functionDefinition) |
| 4586 ..add(_expression) | 3801 ..add(_expression) |
| 4587 ..add(semicolon); | 3802 ..add(semicolon); |
| 4588 | 3803 |
| 4589 @override | 3804 @override |
| 4590 Token get endToken { | 3805 Token get endToken { |
| 4591 if (semicolon != null) { | 3806 if (semicolon != null) { |
| 4592 return semicolon; | 3807 return semicolon; |
| 4593 } | 3808 } |
| 4594 return _expression.endToken; | 3809 return _expression.endToken; |
| 4595 } | 3810 } |
| 4596 | 3811 |
| 4597 /** | 3812 @override |
| 4598 * Return the expression representing the body of the function. | |
| 4599 */ | |
| 4600 Expression get expression => _expression; | 3813 Expression get expression => _expression; |
| 4601 | 3814 |
| 4602 /** | 3815 @override |
| 4603 * Set the expression representing the body of the function to the given | |
| 4604 * [expression]. | |
| 4605 */ | |
| 4606 void set expression(Expression expression) { | 3816 void set expression(Expression expression) { |
| 4607 _expression = _becomeParentOf(expression); | 3817 _expression = _becomeParentOf(expression); |
| 4608 } | 3818 } |
| 4609 | 3819 |
| 4610 @override | 3820 @override |
| 4611 bool get isAsynchronous => keyword != null; | 3821 bool get isAsynchronous => keyword != null; |
| 4612 | 3822 |
| 4613 @override | 3823 @override |
| 4614 bool get isSynchronous => keyword == null; | 3824 bool get isSynchronous => keyword == null; |
| 4615 | 3825 |
| 4616 @override | 3826 @override |
| 4617 accept(AstVisitor visitor) => visitor.visitExpressionFunctionBody(this); | 3827 accept(AstVisitor visitor) => visitor.visitExpressionFunctionBody(this); |
| 4618 | 3828 |
| 4619 @override | 3829 @override |
| 4620 void visitChildren(AstVisitor visitor) { | 3830 void visitChildren(AstVisitor visitor) { |
| 4621 _safelyVisitChild(_expression, visitor); | 3831 _safelyVisitChild(_expression, visitor); |
| 4622 } | 3832 } |
| 4623 } | 3833 } |
| 4624 | 3834 |
| 4625 /** | 3835 /** |
| 3836 * A node that represents an expression. |
| 3837 * |
| 3838 * > expression ::= |
| 3839 * > [AssignmentExpression] |
| 3840 * > | [ConditionalExpression] cascadeSection* |
| 3841 * > | [ThrowExpression] |
| 3842 */ |
| 3843 abstract class ExpressionImpl extends AstNodeImpl implements Expression { |
| 3844 /** |
| 3845 * The static type of this expression, or `null` if the AST structure has not |
| 3846 * been resolved. |
| 3847 */ |
| 3848 DartType staticType; |
| 3849 |
| 3850 /** |
| 3851 * The propagated type of this expression, or `null` if type propagation has |
| 3852 * not been performed on the AST structure. |
| 3853 */ |
| 3854 DartType propagatedType; |
| 3855 |
| 3856 /** |
| 3857 * Return the best parameter element information available for this |
| 3858 * expression. If type propagation was able to find a better parameter element |
| 3859 * than static analysis, that type will be returned. Otherwise, the result of |
| 3860 * static analysis will be returned. |
| 3861 */ |
| 3862 ParameterElement get bestParameterElement { |
| 3863 ParameterElement propagatedElement = propagatedParameterElement; |
| 3864 if (propagatedElement != null) { |
| 3865 return propagatedElement; |
| 3866 } |
| 3867 return staticParameterElement; |
| 3868 } |
| 3869 |
| 3870 @override |
| 3871 DartType get bestType { |
| 3872 if (propagatedType != null) { |
| 3873 return propagatedType; |
| 3874 } else if (staticType != null) { |
| 3875 return staticType; |
| 3876 } |
| 3877 return DynamicTypeImpl.instance; |
| 3878 } |
| 3879 |
| 3880 @override |
| 3881 bool get isAssignable => false; |
| 3882 |
| 3883 @override |
| 3884 ParameterElement get propagatedParameterElement { |
| 3885 AstNode parent = this.parent; |
| 3886 if (parent is ArgumentListImpl) { |
| 3887 return parent._getPropagatedParameterElementFor(this); |
| 3888 } else if (parent is IndexExpressionImpl) { |
| 3889 if (identical(parent.index, this)) { |
| 3890 return parent._propagatedParameterElementForIndex; |
| 3891 } |
| 3892 } else if (parent is BinaryExpressionImpl) { |
| 3893 if (identical(parent.rightOperand, this)) { |
| 3894 return parent._propagatedParameterElementForRightOperand; |
| 3895 } |
| 3896 } else if (parent is AssignmentExpressionImpl) { |
| 3897 if (identical(parent.rightHandSide, this)) { |
| 3898 return parent._propagatedParameterElementForRightHandSide; |
| 3899 } |
| 3900 } else if (parent is PrefixExpressionImpl) { |
| 3901 return parent._propagatedParameterElementForOperand; |
| 3902 } else if (parent is PostfixExpressionImpl) { |
| 3903 return parent._propagatedParameterElementForOperand; |
| 3904 } |
| 3905 return null; |
| 3906 } |
| 3907 |
| 3908 @override |
| 3909 ParameterElement get staticParameterElement { |
| 3910 AstNode parent = this.parent; |
| 3911 if (parent is ArgumentListImpl) { |
| 3912 return parent._getStaticParameterElementFor(this); |
| 3913 } else if (parent is IndexExpressionImpl) { |
| 3914 if (identical(parent.index, this)) { |
| 3915 return parent._staticParameterElementForIndex; |
| 3916 } |
| 3917 } else if (parent is BinaryExpressionImpl) { |
| 3918 if (identical(parent.rightOperand, this)) { |
| 3919 return parent._staticParameterElementForRightOperand; |
| 3920 } |
| 3921 } else if (parent is AssignmentExpressionImpl) { |
| 3922 if (identical(parent.rightHandSide, this)) { |
| 3923 return parent._staticParameterElementForRightHandSide; |
| 3924 } |
| 3925 } else if (parent is PrefixExpressionImpl) { |
| 3926 return parent._staticParameterElementForOperand; |
| 3927 } else if (parent is PostfixExpressionImpl) { |
| 3928 return parent._staticParameterElementForOperand; |
| 3929 } |
| 3930 return null; |
| 3931 } |
| 3932 } |
| 3933 |
| 3934 /** |
| 4626 * An expression used as a statement. | 3935 * An expression used as a statement. |
| 4627 * | 3936 * |
| 4628 * > expressionStatement ::= | 3937 * > expressionStatement ::= |
| 4629 * > [Expression]? ';' | 3938 * > [Expression]? ';' |
| 4630 */ | 3939 */ |
| 4631 class ExpressionStatement extends Statement { | 3940 class ExpressionStatementImpl extends StatementImpl |
| 3941 implements ExpressionStatement { |
| 4632 /** | 3942 /** |
| 4633 * The expression that comprises the statement. | 3943 * The expression that comprises the statement. |
| 4634 */ | 3944 */ |
| 4635 Expression _expression; | 3945 Expression _expression; |
| 4636 | 3946 |
| 4637 /** | 3947 /** |
| 4638 * The semicolon terminating the statement, or `null` if the expression is a | 3948 * The semicolon terminating the statement, or `null` if the expression is a |
| 4639 * function expression and therefore isn't followed by a semicolon. | 3949 * function expression and therefore isn't followed by a semicolon. |
| 4640 */ | 3950 */ |
| 4641 Token semicolon; | 3951 Token semicolon; |
| 4642 | 3952 |
| 4643 /** | 3953 /** |
| 4644 * Initialize a newly created expression statement. | 3954 * Initialize a newly created expression statement. |
| 4645 */ | 3955 */ |
| 4646 ExpressionStatement(Expression expression, this.semicolon) { | 3956 ExpressionStatementImpl(Expression expression, this.semicolon) { |
| 4647 _expression = _becomeParentOf(expression); | 3957 _expression = _becomeParentOf(expression); |
| 4648 } | 3958 } |
| 4649 | 3959 |
| 4650 @override | 3960 @override |
| 4651 Token get beginToken => _expression.beginToken; | 3961 Token get beginToken => _expression.beginToken; |
| 4652 | 3962 |
| 4653 @override | 3963 @override |
| 4654 Iterable get childEntities => | 3964 Iterable get childEntities => |
| 4655 new ChildEntities()..add(_expression)..add(semicolon); | 3965 new ChildEntities()..add(_expression)..add(semicolon); |
| 4656 | 3966 |
| 4657 @override | 3967 @override |
| 4658 Token get endToken { | 3968 Token get endToken { |
| 4659 if (semicolon != null) { | 3969 if (semicolon != null) { |
| 4660 return semicolon; | 3970 return semicolon; |
| 4661 } | 3971 } |
| 4662 return _expression.endToken; | 3972 return _expression.endToken; |
| 4663 } | 3973 } |
| 4664 | 3974 |
| 4665 /** | 3975 @override |
| 4666 * Return the expression that comprises the statement. | |
| 4667 */ | |
| 4668 Expression get expression => _expression; | 3976 Expression get expression => _expression; |
| 4669 | 3977 |
| 4670 /** | 3978 @override |
| 4671 * Set the expression that comprises the statement to the given [expression]. | |
| 4672 */ | |
| 4673 void set expression(Expression expression) { | 3979 void set expression(Expression expression) { |
| 4674 _expression = _becomeParentOf(expression); | 3980 _expression = _becomeParentOf(expression); |
| 4675 } | 3981 } |
| 4676 | 3982 |
| 4677 @override | 3983 @override |
| 4678 bool get isSynthetic => _expression.isSynthetic && semicolon.isSynthetic; | 3984 bool get isSynthetic => _expression.isSynthetic && semicolon.isSynthetic; |
| 4679 | 3985 |
| 4680 @override | 3986 @override |
| 4681 accept(AstVisitor visitor) => visitor.visitExpressionStatement(this); | 3987 accept(AstVisitor visitor) => visitor.visitExpressionStatement(this); |
| 4682 | 3988 |
| 4683 @override | 3989 @override |
| 4684 void visitChildren(AstVisitor visitor) { | 3990 void visitChildren(AstVisitor visitor) { |
| 4685 _safelyVisitChild(_expression, visitor); | 3991 _safelyVisitChild(_expression, visitor); |
| 4686 } | 3992 } |
| 4687 } | 3993 } |
| 4688 | 3994 |
| 4689 /** | 3995 /** |
| 4690 * The "extends" clause in a class declaration. | 3996 * The "extends" clause in a class declaration. |
| 4691 * | 3997 * |
| 4692 * > extendsClause ::= | 3998 * > extendsClause ::= |
| 4693 * > 'extends' [TypeName] | 3999 * > 'extends' [TypeName] |
| 4694 */ | 4000 */ |
| 4695 class ExtendsClause extends AstNode { | 4001 class ExtendsClauseImpl extends AstNodeImpl implements ExtendsClause { |
| 4696 /** | 4002 /** |
| 4697 * The token representing the 'extends' keyword. | 4003 * The token representing the 'extends' keyword. |
| 4698 */ | 4004 */ |
| 4699 Token extendsKeyword; | 4005 Token extendsKeyword; |
| 4700 | 4006 |
| 4701 /** | 4007 /** |
| 4702 * The name of the class that is being extended. | 4008 * The name of the class that is being extended. |
| 4703 */ | 4009 */ |
| 4704 TypeName _superclass; | 4010 TypeName _superclass; |
| 4705 | 4011 |
| 4706 /** | 4012 /** |
| 4707 * Initialize a newly created extends clause. | 4013 * Initialize a newly created extends clause. |
| 4708 */ | 4014 */ |
| 4709 ExtendsClause(this.extendsKeyword, TypeName superclass) { | 4015 ExtendsClauseImpl(this.extendsKeyword, TypeName superclass) { |
| 4710 _superclass = _becomeParentOf(superclass); | 4016 _superclass = _becomeParentOf(superclass); |
| 4711 } | 4017 } |
| 4712 | 4018 |
| 4713 @override | 4019 @override |
| 4714 Token get beginToken => extendsKeyword; | 4020 Token get beginToken => extendsKeyword; |
| 4715 | 4021 |
| 4716 @override | 4022 @override |
| 4717 Iterable get childEntities => | 4023 Iterable get childEntities => |
| 4718 new ChildEntities()..add(extendsKeyword)..add(_superclass); | 4024 new ChildEntities()..add(extendsKeyword)..add(_superclass); |
| 4719 | 4025 |
| 4720 @override | 4026 @override |
| 4721 Token get endToken => _superclass.endToken; | 4027 Token get endToken => _superclass.endToken; |
| 4722 | 4028 |
| 4723 /** | 4029 @override |
| 4724 * Return the name of the class that is being extended. | |
| 4725 */ | |
| 4726 TypeName get superclass => _superclass; | 4030 TypeName get superclass => _superclass; |
| 4727 | 4031 |
| 4728 /** | 4032 @override |
| 4729 * Set the name of the class that is being extended to the given [name]. | |
| 4730 */ | |
| 4731 void set superclass(TypeName name) { | 4033 void set superclass(TypeName name) { |
| 4732 _superclass = _becomeParentOf(name); | 4034 _superclass = _becomeParentOf(name); |
| 4733 } | 4035 } |
| 4734 | 4036 |
| 4735 @override | 4037 @override |
| 4736 accept(AstVisitor visitor) => visitor.visitExtendsClause(this); | 4038 accept(AstVisitor visitor) => visitor.visitExtendsClause(this); |
| 4737 | 4039 |
| 4738 @override | 4040 @override |
| 4739 void visitChildren(AstVisitor visitor) { | 4041 void visitChildren(AstVisitor visitor) { |
| 4740 _safelyVisitChild(_superclass, visitor); | 4042 _safelyVisitChild(_superclass, visitor); |
| 4741 } | 4043 } |
| 4742 } | 4044 } |
| 4743 | 4045 |
| 4744 /** | 4046 /** |
| 4745 * The declaration of one or more fields of the same type. | 4047 * The declaration of one or more fields of the same type. |
| 4746 * | 4048 * |
| 4747 * > fieldDeclaration ::= | 4049 * > fieldDeclaration ::= |
| 4748 * > 'static'? [VariableDeclarationList] ';' | 4050 * > 'static'? [VariableDeclarationList] ';' |
| 4749 */ | 4051 */ |
| 4750 class FieldDeclaration extends ClassMember { | 4052 class FieldDeclarationImpl extends ClassMemberImpl implements FieldDeclaration { |
| 4751 /** | 4053 /** |
| 4752 * The token representing the 'static' keyword, or `null` if the fields are | 4054 * The token representing the 'static' keyword, or `null` if the fields are |
| 4753 * not static. | 4055 * not static. |
| 4754 */ | 4056 */ |
| 4755 Token staticKeyword; | 4057 Token staticKeyword; |
| 4756 | 4058 |
| 4757 /** | 4059 /** |
| 4758 * The fields being declared. | 4060 * The fields being declared. |
| 4759 */ | 4061 */ |
| 4760 VariableDeclarationList _fieldList; | 4062 VariableDeclarationList _fieldList; |
| 4761 | 4063 |
| 4762 /** | 4064 /** |
| 4763 * The semicolon terminating the declaration. | 4065 * The semicolon terminating the declaration. |
| 4764 */ | 4066 */ |
| 4765 Token semicolon; | 4067 Token semicolon; |
| 4766 | 4068 |
| 4767 /** | 4069 /** |
| 4768 * Initialize a newly created field declaration. Either or both of the | 4070 * Initialize a newly created field declaration. Either or both of the |
| 4769 * [comment] and [metadata] can be `null` if the declaration does not have the | 4071 * [comment] and [metadata] can be `null` if the declaration does not have the |
| 4770 * corresponding attribute. The [staticKeyword] can be `null` if the field is | 4072 * corresponding attribute. The [staticKeyword] can be `null` if the field is |
| 4771 * not a static field. | 4073 * not a static field. |
| 4772 */ | 4074 */ |
| 4773 FieldDeclaration(Comment comment, List<Annotation> metadata, | 4075 FieldDeclarationImpl(Comment comment, List<Annotation> metadata, |
| 4774 this.staticKeyword, VariableDeclarationList fieldList, this.semicolon) | 4076 this.staticKeyword, VariableDeclarationList fieldList, this.semicolon) |
| 4775 : super(comment, metadata) { | 4077 : super(comment, metadata) { |
| 4776 _fieldList = _becomeParentOf(fieldList); | 4078 _fieldList = _becomeParentOf(fieldList); |
| 4777 } | 4079 } |
| 4778 | 4080 |
| 4779 @override | 4081 @override |
| 4780 Iterable get childEntities => | 4082 Iterable get childEntities => |
| 4781 super._childEntities..add(staticKeyword)..add(_fieldList)..add(semicolon); | 4083 super._childEntities..add(staticKeyword)..add(_fieldList)..add(semicolon); |
| 4782 | 4084 |
| 4783 @override | 4085 @override |
| 4784 Element get element => null; | 4086 Element get element => null; |
| 4785 | 4087 |
| 4786 @override | 4088 @override |
| 4787 Token get endToken => semicolon; | 4089 Token get endToken => semicolon; |
| 4788 | 4090 |
| 4789 /** | 4091 @override |
| 4790 * Return the fields being declared. | |
| 4791 */ | |
| 4792 VariableDeclarationList get fields => _fieldList; | 4092 VariableDeclarationList get fields => _fieldList; |
| 4793 | 4093 |
| 4794 /** | 4094 @override |
| 4795 * Set the fields being declared to the given list of [fields]. | |
| 4796 */ | |
| 4797 void set fields(VariableDeclarationList fields) { | 4095 void set fields(VariableDeclarationList fields) { |
| 4798 _fieldList = _becomeParentOf(fields); | 4096 _fieldList = _becomeParentOf(fields); |
| 4799 } | 4097 } |
| 4800 | 4098 |
| 4801 @override | 4099 @override |
| 4802 Token get firstTokenAfterCommentAndMetadata { | 4100 Token get firstTokenAfterCommentAndMetadata { |
| 4803 if (staticKeyword != null) { | 4101 if (staticKeyword != null) { |
| 4804 return staticKeyword; | 4102 return staticKeyword; |
| 4805 } | 4103 } |
| 4806 return _fieldList.beginToken; | 4104 return _fieldList.beginToken; |
| 4807 } | 4105 } |
| 4808 | 4106 |
| 4809 /** | 4107 @override |
| 4810 * Return `true` if the fields are declared to be static. | |
| 4811 */ | |
| 4812 bool get isStatic => staticKeyword != null; | 4108 bool get isStatic => staticKeyword != null; |
| 4813 | 4109 |
| 4814 @override | 4110 @override |
| 4815 accept(AstVisitor visitor) => visitor.visitFieldDeclaration(this); | 4111 accept(AstVisitor visitor) => visitor.visitFieldDeclaration(this); |
| 4816 | 4112 |
| 4817 @override | 4113 @override |
| 4818 void visitChildren(AstVisitor visitor) { | 4114 void visitChildren(AstVisitor visitor) { |
| 4819 super.visitChildren(visitor); | 4115 super.visitChildren(visitor); |
| 4820 _safelyVisitChild(_fieldList, visitor); | 4116 _safelyVisitChild(_fieldList, visitor); |
| 4821 } | 4117 } |
| 4822 } | 4118 } |
| 4823 | 4119 |
| 4824 /** | 4120 /** |
| 4825 * A field formal parameter. | 4121 * A field formal parameter. |
| 4826 * | 4122 * |
| 4827 * > fieldFormalParameter ::= | 4123 * > fieldFormalParameter ::= |
| 4828 * > ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])? | 4124 * > ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])? |
| 4829 * > 'this' '.' [SimpleIdentifier] ([TypeParameterList]? [FormalParameterLis
t])? | 4125 * > 'this' '.' [SimpleIdentifier] ([TypeParameterList]? [FormalParameterLis
t])? |
| 4830 */ | 4126 */ |
| 4831 class FieldFormalParameter extends NormalFormalParameter { | 4127 class FieldFormalParameterImpl extends NormalFormalParameterImpl |
| 4128 implements FieldFormalParameter { |
| 4832 /** | 4129 /** |
| 4833 * The token representing either the 'final', 'const' or 'var' keyword, or | 4130 * The token representing either the 'final', 'const' or 'var' keyword, or |
| 4834 * `null` if no keyword was used. | 4131 * `null` if no keyword was used. |
| 4835 */ | 4132 */ |
| 4836 Token keyword; | 4133 Token keyword; |
| 4837 | 4134 |
| 4838 /** | 4135 /** |
| 4839 * The name of the declared type of the parameter, or `null` if the parameter | 4136 * The name of the declared type of the parameter, or `null` if the parameter |
| 4840 * does not have a declared type. | 4137 * does not have a declared type. |
| 4841 */ | 4138 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4865 | 4162 |
| 4866 /** | 4163 /** |
| 4867 * Initialize a newly created formal parameter. Either or both of the | 4164 * Initialize a newly created formal parameter. Either or both of the |
| 4868 * [comment] and [metadata] can be `null` if the parameter does not have the | 4165 * [comment] and [metadata] can be `null` if the parameter does not have the |
| 4869 * corresponding attribute. The [keyword] can be `null` if there is a type. | 4166 * corresponding attribute. The [keyword] can be `null` if there is a type. |
| 4870 * The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and | 4167 * The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and |
| 4871 * [period] can be `null` if the keyword 'this' was not provided. The | 4168 * [period] can be `null` if the keyword 'this' was not provided. The |
| 4872 * [parameters] can be `null` if this is not a function-typed field formal | 4169 * [parameters] can be `null` if this is not a function-typed field formal |
| 4873 * parameter. | 4170 * parameter. |
| 4874 */ | 4171 */ |
| 4875 FieldFormalParameter( | 4172 FieldFormalParameterImpl( |
| 4876 Comment comment, | 4173 Comment comment, |
| 4877 List<Annotation> metadata, | 4174 List<Annotation> metadata, |
| 4878 this.keyword, | 4175 this.keyword, |
| 4879 TypeName type, | 4176 TypeName type, |
| 4880 this.thisKeyword, | 4177 this.thisKeyword, |
| 4881 this.period, | 4178 this.period, |
| 4882 SimpleIdentifier identifier, | 4179 SimpleIdentifier identifier, |
| 4883 TypeParameterList typeParameters, | 4180 TypeParameterList typeParameters, |
| 4884 FormalParameterList parameters) | 4181 FormalParameterList parameters) |
| 4885 : super(comment, metadata, identifier) { | 4182 : super(comment, metadata, identifier) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4918 @override | 4215 @override |
| 4919 bool get isConst => | 4216 bool get isConst => |
| 4920 (keyword is KeywordToken) && | 4217 (keyword is KeywordToken) && |
| 4921 (keyword as KeywordToken).keyword == Keyword.CONST; | 4218 (keyword as KeywordToken).keyword == Keyword.CONST; |
| 4922 | 4219 |
| 4923 @override | 4220 @override |
| 4924 bool get isFinal => | 4221 bool get isFinal => |
| 4925 (keyword is KeywordToken) && | 4222 (keyword is KeywordToken) && |
| 4926 (keyword as KeywordToken).keyword == Keyword.FINAL; | 4223 (keyword as KeywordToken).keyword == Keyword.FINAL; |
| 4927 | 4224 |
| 4928 /** | 4225 @override |
| 4929 * Return the parameters of the function-typed parameter, or `null` if this is | |
| 4930 * not a function-typed field formal parameter. | |
| 4931 */ | |
| 4932 FormalParameterList get parameters => _parameters; | 4226 FormalParameterList get parameters => _parameters; |
| 4933 | 4227 |
| 4934 /** | 4228 @override |
| 4935 * Set the parameters of the function-typed parameter to the given | |
| 4936 * [parameters]. | |
| 4937 */ | |
| 4938 void set parameters(FormalParameterList parameters) { | 4229 void set parameters(FormalParameterList parameters) { |
| 4939 _parameters = _becomeParentOf(parameters); | 4230 _parameters = _becomeParentOf(parameters); |
| 4940 } | 4231 } |
| 4941 | 4232 |
| 4942 /** | 4233 @override |
| 4943 * Return the name of the declared type of the parameter, or `null` if the | |
| 4944 * parameter does not have a declared type. Note that if this is a | |
| 4945 * function-typed field formal parameter this is the return type of the | |
| 4946 * function. | |
| 4947 */ | |
| 4948 TypeName get type => _type; | 4234 TypeName get type => _type; |
| 4949 | 4235 |
| 4950 /** | 4236 @override |
| 4951 * Set the name of the declared type of the parameter to the given [typeName]. | |
| 4952 */ | |
| 4953 void set type(TypeName typeName) { | 4237 void set type(TypeName typeName) { |
| 4954 _type = _becomeParentOf(typeName); | 4238 _type = _becomeParentOf(typeName); |
| 4955 } | 4239 } |
| 4956 | 4240 |
| 4957 /** | 4241 @override |
| 4958 * Return the type parameters associated with this method, or `null` if this | |
| 4959 * method is not a generic method. | |
| 4960 */ | |
| 4961 TypeParameterList get typeParameters => _typeParameters; | 4242 TypeParameterList get typeParameters => _typeParameters; |
| 4962 | 4243 |
| 4963 /** | 4244 @override |
| 4964 * Set the type parameters associated with this method to the given | |
| 4965 * [typeParameters]. | |
| 4966 */ | |
| 4967 void set typeParameters(TypeParameterList typeParameters) { | 4245 void set typeParameters(TypeParameterList typeParameters) { |
| 4968 _typeParameters = _becomeParentOf(typeParameters); | 4246 _typeParameters = _becomeParentOf(typeParameters); |
| 4969 } | 4247 } |
| 4970 | 4248 |
| 4971 @override | 4249 @override |
| 4972 accept(AstVisitor visitor) => visitor.visitFieldFormalParameter(this); | 4250 accept(AstVisitor visitor) => visitor.visitFieldFormalParameter(this); |
| 4973 | 4251 |
| 4974 @override | 4252 @override |
| 4975 void visitChildren(AstVisitor visitor) { | 4253 void visitChildren(AstVisitor visitor) { |
| 4976 super.visitChildren(visitor); | 4254 super.visitChildren(visitor); |
| 4977 _safelyVisitChild(_type, visitor); | 4255 _safelyVisitChild(_type, visitor); |
| 4978 _safelyVisitChild(identifier, visitor); | 4256 _safelyVisitChild(identifier, visitor); |
| 4979 _safelyVisitChild(_typeParameters, visitor); | 4257 _safelyVisitChild(_typeParameters, visitor); |
| 4980 _safelyVisitChild(_parameters, visitor); | 4258 _safelyVisitChild(_parameters, visitor); |
| 4981 } | 4259 } |
| 4982 } | 4260 } |
| 4983 | 4261 |
| 4984 /** | 4262 /** |
| 4985 * A for-each statement. | 4263 * A for-each statement. |
| 4986 * | 4264 * |
| 4987 * > forEachStatement ::= | 4265 * > forEachStatement ::= |
| 4988 * > 'await'? 'for' '(' [DeclaredIdentifier] 'in' [Expression] ')' [Block] | 4266 * > 'await'? 'for' '(' [DeclaredIdentifier] 'in' [Expression] ')' [Block] |
| 4989 * > | 'await'? 'for' '(' [SimpleIdentifier] 'in' [Expression] ')' [Block] | 4267 * > | 'await'? 'for' '(' [SimpleIdentifier] 'in' [Expression] ')' [Block] |
| 4990 */ | 4268 */ |
| 4991 class ForEachStatement extends Statement { | 4269 class ForEachStatementImpl extends StatementImpl implements ForEachStatement { |
| 4992 /** | 4270 /** |
| 4993 * The token representing the 'await' keyword, or `null` if there is no | 4271 * The token representing the 'await' keyword, or `null` if there is no |
| 4994 * 'await' keyword. | 4272 * 'await' keyword. |
| 4995 */ | 4273 */ |
| 4996 Token awaitKeyword; | 4274 Token awaitKeyword; |
| 4997 | 4275 |
| 4998 /** | 4276 /** |
| 4999 * The token representing the 'for' keyword. | 4277 * The token representing the 'for' keyword. |
| 5000 */ | 4278 */ |
| 5001 Token forKeyword; | 4279 Token forKeyword; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5034 /** | 4312 /** |
| 5035 * The body of the loop. | 4313 * The body of the loop. |
| 5036 */ | 4314 */ |
| 5037 Statement _body; | 4315 Statement _body; |
| 5038 | 4316 |
| 5039 /** | 4317 /** |
| 5040 * Initialize a newly created for-each statement whose loop control variable | 4318 * Initialize a newly created for-each statement whose loop control variable |
| 5041 * is declared internally (in the for-loop part). The [awaitKeyword] can be | 4319 * is declared internally (in the for-loop part). The [awaitKeyword] can be |
| 5042 * `null` if this is not an asynchronous for loop. | 4320 * `null` if this is not an asynchronous for loop. |
| 5043 */ | 4321 */ |
| 5044 ForEachStatement.withDeclaration( | 4322 ForEachStatementImpl.withDeclaration( |
| 5045 this.awaitKeyword, | 4323 this.awaitKeyword, |
| 5046 this.forKeyword, | 4324 this.forKeyword, |
| 5047 this.leftParenthesis, | 4325 this.leftParenthesis, |
| 5048 DeclaredIdentifier loopVariable, | 4326 DeclaredIdentifier loopVariable, |
| 5049 this.inKeyword, | 4327 this.inKeyword, |
| 5050 Expression iterator, | 4328 Expression iterator, |
| 5051 this.rightParenthesis, | 4329 this.rightParenthesis, |
| 5052 Statement body) { | 4330 Statement body) { |
| 5053 _loopVariable = _becomeParentOf(loopVariable); | 4331 _loopVariable = _becomeParentOf(loopVariable); |
| 5054 _iterable = _becomeParentOf(iterator); | 4332 _iterable = _becomeParentOf(iterator); |
| 5055 _body = _becomeParentOf(body); | 4333 _body = _becomeParentOf(body); |
| 5056 } | 4334 } |
| 5057 | 4335 |
| 5058 /** | 4336 /** |
| 5059 * Initialize a newly created for-each statement whose loop control variable | 4337 * Initialize a newly created for-each statement whose loop control variable |
| 5060 * is declared outside the for loop. The [awaitKeyword] can be `null` if this | 4338 * is declared outside the for loop. The [awaitKeyword] can be `null` if this |
| 5061 * is not an asynchronous for loop. | 4339 * is not an asynchronous for loop. |
| 5062 */ | 4340 */ |
| 5063 ForEachStatement.withReference( | 4341 ForEachStatementImpl.withReference( |
| 5064 this.awaitKeyword, | 4342 this.awaitKeyword, |
| 5065 this.forKeyword, | 4343 this.forKeyword, |
| 5066 this.leftParenthesis, | 4344 this.leftParenthesis, |
| 5067 SimpleIdentifier identifier, | 4345 SimpleIdentifier identifier, |
| 5068 this.inKeyword, | 4346 this.inKeyword, |
| 5069 Expression iterator, | 4347 Expression iterator, |
| 5070 this.rightParenthesis, | 4348 this.rightParenthesis, |
| 5071 Statement body) { | 4349 Statement body) { |
| 5072 _identifier = _becomeParentOf(identifier); | 4350 _identifier = _becomeParentOf(identifier); |
| 5073 _iterable = _becomeParentOf(iterator); | 4351 _iterable = _becomeParentOf(iterator); |
| 5074 _body = _becomeParentOf(body); | 4352 _body = _becomeParentOf(body); |
| 5075 } | 4353 } |
| 5076 | 4354 |
| 5077 @override | 4355 @override |
| 5078 Token get beginToken => forKeyword; | 4356 Token get beginToken => forKeyword; |
| 5079 | 4357 |
| 5080 /** | 4358 @override |
| 5081 * Return the body of the loop. | |
| 5082 */ | |
| 5083 Statement get body => _body; | 4359 Statement get body => _body; |
| 5084 | 4360 |
| 5085 /** | 4361 @override |
| 5086 * Set the body of the loop to the given [statement]. | |
| 5087 */ | |
| 5088 void set body(Statement statement) { | 4362 void set body(Statement statement) { |
| 5089 _body = _becomeParentOf(statement); | 4363 _body = _becomeParentOf(statement); |
| 5090 } | 4364 } |
| 5091 | 4365 |
| 5092 @override | 4366 @override |
| 5093 Iterable get childEntities => new ChildEntities() | 4367 Iterable get childEntities => new ChildEntities() |
| 5094 ..add(awaitKeyword) | 4368 ..add(awaitKeyword) |
| 5095 ..add(forKeyword) | 4369 ..add(forKeyword) |
| 5096 ..add(leftParenthesis) | 4370 ..add(leftParenthesis) |
| 5097 ..add(_loopVariable) | 4371 ..add(_loopVariable) |
| 5098 ..add(_identifier) | 4372 ..add(_identifier) |
| 5099 ..add(inKeyword) | 4373 ..add(inKeyword) |
| 5100 ..add(_iterable) | 4374 ..add(_iterable) |
| 5101 ..add(rightParenthesis) | 4375 ..add(rightParenthesis) |
| 5102 ..add(_body); | 4376 ..add(_body); |
| 5103 | 4377 |
| 5104 @override | 4378 @override |
| 5105 Token get endToken => _body.endToken; | 4379 Token get endToken => _body.endToken; |
| 5106 | 4380 |
| 5107 /** | 4381 @override |
| 5108 * Return the loop variable, or `null` if the loop variable is declared in the | |
| 5109 * 'for'. | |
| 5110 */ | |
| 5111 SimpleIdentifier get identifier => _identifier; | 4382 SimpleIdentifier get identifier => _identifier; |
| 5112 | 4383 |
| 5113 /** | 4384 @override |
| 5114 * Set the loop variable to the given [identifier]. | |
| 5115 */ | |
| 5116 void set identifier(SimpleIdentifier identifier) { | 4385 void set identifier(SimpleIdentifier identifier) { |
| 5117 _identifier = _becomeParentOf(identifier); | 4386 _identifier = _becomeParentOf(identifier); |
| 5118 } | 4387 } |
| 5119 | 4388 |
| 5120 /** | 4389 @override |
| 5121 * Return the expression evaluated to produce the iterator. | |
| 5122 */ | |
| 5123 Expression get iterable => _iterable; | 4390 Expression get iterable => _iterable; |
| 5124 | 4391 |
| 5125 /** | 4392 @override |
| 5126 * Set the expression evaluated to produce the iterator to the given | |
| 5127 * [expression]. | |
| 5128 */ | |
| 5129 void set iterable(Expression expression) { | 4393 void set iterable(Expression expression) { |
| 5130 _iterable = _becomeParentOf(expression); | 4394 _iterable = _becomeParentOf(expression); |
| 5131 } | 4395 } |
| 5132 | 4396 |
| 5133 /** | 4397 @override |
| 5134 * Return the declaration of the loop variable, or `null` if the loop variable | |
| 5135 * is a simple identifier. | |
| 5136 */ | |
| 5137 DeclaredIdentifier get loopVariable => _loopVariable; | 4398 DeclaredIdentifier get loopVariable => _loopVariable; |
| 5138 | 4399 |
| 5139 /** | 4400 @override |
| 5140 * Set the declaration of the loop variable to the given [variable]. | |
| 5141 */ | |
| 5142 void set loopVariable(DeclaredIdentifier variable) { | 4401 void set loopVariable(DeclaredIdentifier variable) { |
| 5143 _loopVariable = _becomeParentOf(variable); | 4402 _loopVariable = _becomeParentOf(variable); |
| 5144 } | 4403 } |
| 5145 | 4404 |
| 5146 @override | 4405 @override |
| 5147 accept(AstVisitor visitor) => visitor.visitForEachStatement(this); | 4406 accept(AstVisitor visitor) => visitor.visitForEachStatement(this); |
| 5148 | 4407 |
| 5149 @override | 4408 @override |
| 5150 void visitChildren(AstVisitor visitor) { | 4409 void visitChildren(AstVisitor visitor) { |
| 5151 _safelyVisitChild(_loopVariable, visitor); | 4410 _safelyVisitChild(_loopVariable, visitor); |
| 5152 _safelyVisitChild(_identifier, visitor); | 4411 _safelyVisitChild(_identifier, visitor); |
| 5153 _safelyVisitChild(_iterable, visitor); | 4412 _safelyVisitChild(_iterable, visitor); |
| 5154 _safelyVisitChild(_body, visitor); | 4413 _safelyVisitChild(_body, visitor); |
| 5155 } | 4414 } |
| 5156 } | 4415 } |
| 5157 | 4416 |
| 5158 /** | 4417 /** |
| 5159 * A node representing a parameter to a function. | 4418 * A node representing a parameter to a function. |
| 5160 * | 4419 * |
| 5161 * > formalParameter ::= | 4420 * > formalParameter ::= |
| 5162 * > [NormalFormalParameter] | 4421 * > [NormalFormalParameter] |
| 5163 * > | [DefaultFormalParameter] | 4422 * > | [DefaultFormalParameter] |
| 5164 */ | 4423 */ |
| 5165 abstract class FormalParameter extends AstNode { | 4424 abstract class FormalParameterImpl extends AstNodeImpl |
| 5166 /** | 4425 implements FormalParameter { |
| 5167 * Return the element representing this parameter, or `null` if this parameter | 4426 @override |
| 5168 * has not been resolved. | |
| 5169 */ | |
| 5170 ParameterElement get element { | 4427 ParameterElement get element { |
| 5171 SimpleIdentifier identifier = this.identifier; | 4428 SimpleIdentifier identifier = this.identifier; |
| 5172 if (identifier == null) { | 4429 if (identifier == null) { |
| 5173 return null; | 4430 return null; |
| 5174 } | 4431 } |
| 5175 return identifier.staticElement as ParameterElement; | 4432 return identifier.staticElement as ParameterElement; |
| 5176 } | 4433 } |
| 5177 | |
| 5178 /** | |
| 5179 * Return the name of the parameter being declared. | |
| 5180 */ | |
| 5181 SimpleIdentifier get identifier; | |
| 5182 | |
| 5183 /** | |
| 5184 * Return `true` if this parameter was declared with the 'const' modifier. | |
| 5185 */ | |
| 5186 bool get isConst; | |
| 5187 | |
| 5188 /** | |
| 5189 * Return `true` if this parameter was declared with the 'final' modifier. | |
| 5190 * Parameters that are declared with the 'const' modifier will return `false` | |
| 5191 * even though they are implicitly final. | |
| 5192 */ | |
| 5193 bool get isFinal; | |
| 5194 | |
| 5195 /** | |
| 5196 * Return the kind of this parameter. | |
| 5197 */ | |
| 5198 ParameterKind get kind; | |
| 5199 | |
| 5200 /** | |
| 5201 * Return the annotations associated with this parameter. | |
| 5202 */ | |
| 5203 NodeList<Annotation> get metadata; | |
| 5204 } | 4434 } |
| 5205 | 4435 |
| 5206 /** | 4436 /** |
| 5207 * The formal parameter list of a method declaration, function declaration, or | 4437 * The formal parameter list of a method declaration, function declaration, or |
| 5208 * function type alias. | 4438 * function type alias. |
| 5209 * | 4439 * |
| 5210 * While the grammar requires all optional formal parameters to follow all of | 4440 * While the grammar requires all optional formal parameters to follow all of |
| 5211 * the normal formal parameters and at most one grouping of optional formal | 4441 * the normal formal parameters and at most one grouping of optional formal |
| 5212 * parameters, this class does not enforce those constraints. All parameters are | 4442 * parameters, this class does not enforce those constraints. All parameters are |
| 5213 * flattened into a single list, which can have any or all kinds of parameters | 4443 * flattened into a single list, which can have any or all kinds of parameters |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5224 * > optionalFormalParameters ::= | 4454 * > optionalFormalParameters ::= |
| 5225 * > optionalPositionalFormalParameters | 4455 * > optionalPositionalFormalParameters |
| 5226 * > | namedFormalParameters | 4456 * > | namedFormalParameters |
| 5227 * > | 4457 * > |
| 5228 * > optionalPositionalFormalParameters ::= | 4458 * > optionalPositionalFormalParameters ::= |
| 5229 * > '[' [DefaultFormalParameter] (',' [DefaultFormalParameter])* ']' | 4459 * > '[' [DefaultFormalParameter] (',' [DefaultFormalParameter])* ']' |
| 5230 * > | 4460 * > |
| 5231 * > namedFormalParameters ::= | 4461 * > namedFormalParameters ::= |
| 5232 * > '{' [DefaultFormalParameter] (',' [DefaultFormalParameter])* '}' | 4462 * > '{' [DefaultFormalParameter] (',' [DefaultFormalParameter])* '}' |
| 5233 */ | 4463 */ |
| 5234 class FormalParameterList extends AstNode { | 4464 class FormalParameterListImpl extends AstNodeImpl |
| 4465 implements FormalParameterList { |
| 5235 /** | 4466 /** |
| 5236 * The left parenthesis. | 4467 * The left parenthesis. |
| 5237 */ | 4468 */ |
| 5238 Token leftParenthesis; | 4469 Token leftParenthesis; |
| 5239 | 4470 |
| 5240 /** | 4471 /** |
| 5241 * The parameters associated with the method. | 4472 * The parameters associated with the method. |
| 5242 */ | 4473 */ |
| 5243 NodeList<FormalParameter> _parameters; | 4474 NodeList<FormalParameter> _parameters; |
| 5244 | 4475 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5257 /** | 4488 /** |
| 5258 * The right parenthesis. | 4489 * The right parenthesis. |
| 5259 */ | 4490 */ |
| 5260 Token rightParenthesis; | 4491 Token rightParenthesis; |
| 5261 | 4492 |
| 5262 /** | 4493 /** |
| 5263 * Initialize a newly created parameter list. The list of [parameters] can be | 4494 * Initialize a newly created parameter list. The list of [parameters] can be |
| 5264 * `null` if there are no parameters. The [leftDelimiter] and [rightDelimiter] | 4495 * `null` if there are no parameters. The [leftDelimiter] and [rightDelimiter] |
| 5265 * can be `null` if there are no optional parameters. | 4496 * can be `null` if there are no optional parameters. |
| 5266 */ | 4497 */ |
| 5267 FormalParameterList(this.leftParenthesis, List<FormalParameter> parameters, | 4498 FormalParameterListImpl( |
| 5268 this.leftDelimiter, this.rightDelimiter, this.rightParenthesis) { | 4499 this.leftParenthesis, |
| 4500 List<FormalParameter> parameters, |
| 4501 this.leftDelimiter, |
| 4502 this.rightDelimiter, |
| 4503 this.rightParenthesis) { |
| 5269 _parameters = new NodeList<FormalParameter>(this, parameters); | 4504 _parameters = new NodeList<FormalParameter>(this, parameters); |
| 5270 } | 4505 } |
| 5271 | 4506 |
| 5272 @override | 4507 @override |
| 5273 Token get beginToken => leftParenthesis; | 4508 Token get beginToken => leftParenthesis; |
| 5274 | 4509 |
| 5275 @override | 4510 @override |
| 5276 Iterable get childEntities { | 4511 Iterable get childEntities { |
| 5277 // TODO(paulberry): include commas. | 4512 // TODO(paulberry): include commas. |
| 5278 ChildEntities result = new ChildEntities()..add(leftParenthesis); | 4513 ChildEntities result = new ChildEntities()..add(leftParenthesis); |
| 5279 bool leftDelimiterNeeded = leftDelimiter != null; | 4514 bool leftDelimiterNeeded = leftDelimiter != null; |
| 5280 for (FormalParameter parameter in _parameters) { | 4515 for (FormalParameter parameter in _parameters) { |
| 5281 if (leftDelimiterNeeded && leftDelimiter.offset < parameter.offset) { | 4516 if (leftDelimiterNeeded && leftDelimiter.offset < parameter.offset) { |
| 5282 result.add(leftDelimiter); | 4517 result.add(leftDelimiter); |
| 5283 leftDelimiterNeeded = false; | 4518 leftDelimiterNeeded = false; |
| 5284 } | 4519 } |
| 5285 result.add(parameter); | 4520 result.add(parameter); |
| 5286 } | 4521 } |
| 5287 return result..add(rightDelimiter)..add(rightParenthesis); | 4522 return result..add(rightDelimiter)..add(rightParenthesis); |
| 5288 } | 4523 } |
| 5289 | 4524 |
| 5290 @override | 4525 @override |
| 5291 Token get endToken => rightParenthesis; | 4526 Token get endToken => rightParenthesis; |
| 5292 | 4527 |
| 5293 /** | 4528 @override |
| 5294 * Return a list containing the elements representing the parameters in this | |
| 5295 * list. The list will contain `null`s if the parameters in this list have not | |
| 5296 * been resolved. | |
| 5297 */ | |
| 5298 List<ParameterElement> get parameterElements { | 4529 List<ParameterElement> get parameterElements { |
| 5299 int count = _parameters.length; | 4530 int count = _parameters.length; |
| 5300 List<ParameterElement> types = new List<ParameterElement>(count); | 4531 List<ParameterElement> types = new List<ParameterElement>(count); |
| 5301 for (int i = 0; i < count; i++) { | 4532 for (int i = 0; i < count; i++) { |
| 5302 types[i] = _parameters[i].element; | 4533 types[i] = _parameters[i].element; |
| 5303 } | 4534 } |
| 5304 return types; | 4535 return types; |
| 5305 } | 4536 } |
| 5306 | 4537 |
| 5307 /** | 4538 @override |
| 5308 * Return the parameters associated with the method. | |
| 5309 */ | |
| 5310 NodeList<FormalParameter> get parameters => _parameters; | 4539 NodeList<FormalParameter> get parameters => _parameters; |
| 5311 | 4540 |
| 5312 @override | 4541 @override |
| 5313 accept(AstVisitor visitor) => visitor.visitFormalParameterList(this); | 4542 accept(AstVisitor visitor) => visitor.visitFormalParameterList(this); |
| 5314 | 4543 |
| 5315 @override | 4544 @override |
| 5316 void visitChildren(AstVisitor visitor) { | 4545 void visitChildren(AstVisitor visitor) { |
| 5317 _parameters.accept(visitor); | 4546 _parameters.accept(visitor); |
| 5318 } | 4547 } |
| 5319 } | 4548 } |
| 5320 | 4549 |
| 5321 /** | 4550 /** |
| 5322 * A for statement. | 4551 * A for statement. |
| 5323 * | 4552 * |
| 5324 * > forStatement ::= | 4553 * > forStatement ::= |
| 5325 * > 'for' '(' forLoopParts ')' [Statement] | 4554 * > 'for' '(' forLoopParts ')' [Statement] |
| 5326 * > | 4555 * > |
| 5327 * > forLoopParts ::= | 4556 * > forLoopParts ::= |
| 5328 * > forInitializerStatement ';' [Expression]? ';' [Expression]? | 4557 * > forInitializerStatement ';' [Expression]? ';' [Expression]? |
| 5329 * > | 4558 * > |
| 5330 * > forInitializerStatement ::= | 4559 * > forInitializerStatement ::= |
| 5331 * > [DefaultFormalParameter] | 4560 * > [DefaultFormalParameter] |
| 5332 * > | [Expression]? | 4561 * > | [Expression]? |
| 5333 */ | 4562 */ |
| 5334 class ForStatement extends Statement { | 4563 class ForStatementImpl extends StatementImpl implements ForStatement { |
| 5335 /** | 4564 /** |
| 5336 * The token representing the 'for' keyword. | 4565 * The token representing the 'for' keyword. |
| 5337 */ | 4566 */ |
| 5338 Token forKeyword; | 4567 Token forKeyword; |
| 5339 | 4568 |
| 5340 /** | 4569 /** |
| 5341 * The left parenthesis. | 4570 * The left parenthesis. |
| 5342 */ | 4571 */ |
| 5343 Token leftParenthesis; | 4572 Token leftParenthesis; |
| 5344 | 4573 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5386 * The body of the loop. | 4615 * The body of the loop. |
| 5387 */ | 4616 */ |
| 5388 Statement _body; | 4617 Statement _body; |
| 5389 | 4618 |
| 5390 /** | 4619 /** |
| 5391 * Initialize a newly created for statement. Either the [variableList] or the | 4620 * Initialize a newly created for statement. Either the [variableList] or the |
| 5392 * [initialization] must be `null`. Either the [condition] and the list of | 4621 * [initialization] must be `null`. Either the [condition] and the list of |
| 5393 * [updaters] can be `null` if the loop does not have the corresponding | 4622 * [updaters] can be `null` if the loop does not have the corresponding |
| 5394 * attribute. | 4623 * attribute. |
| 5395 */ | 4624 */ |
| 5396 ForStatement( | 4625 ForStatementImpl( |
| 5397 this.forKeyword, | 4626 this.forKeyword, |
| 5398 this.leftParenthesis, | 4627 this.leftParenthesis, |
| 5399 VariableDeclarationList variableList, | 4628 VariableDeclarationList variableList, |
| 5400 Expression initialization, | 4629 Expression initialization, |
| 5401 this.leftSeparator, | 4630 this.leftSeparator, |
| 5402 Expression condition, | 4631 Expression condition, |
| 5403 this.rightSeparator, | 4632 this.rightSeparator, |
| 5404 List<Expression> updaters, | 4633 List<Expression> updaters, |
| 5405 this.rightParenthesis, | 4634 this.rightParenthesis, |
| 5406 Statement body) { | 4635 Statement body) { |
| 5407 _variableList = _becomeParentOf(variableList); | 4636 _variableList = _becomeParentOf(variableList); |
| 5408 _initialization = _becomeParentOf(initialization); | 4637 _initialization = _becomeParentOf(initialization); |
| 5409 _condition = _becomeParentOf(condition); | 4638 _condition = _becomeParentOf(condition); |
| 5410 _updaters = new NodeList<Expression>(this, updaters); | 4639 _updaters = new NodeList<Expression>(this, updaters); |
| 5411 _body = _becomeParentOf(body); | 4640 _body = _becomeParentOf(body); |
| 5412 } | 4641 } |
| 5413 | 4642 |
| 5414 @override | 4643 @override |
| 5415 Token get beginToken => forKeyword; | 4644 Token get beginToken => forKeyword; |
| 5416 | 4645 |
| 5417 /** | 4646 @override |
| 5418 * Return the body of the loop. | |
| 5419 */ | |
| 5420 Statement get body => _body; | 4647 Statement get body => _body; |
| 5421 | 4648 |
| 5422 /** | 4649 @override |
| 5423 * Set the body of the loop to the given [statement]. | |
| 5424 */ | |
| 5425 void set body(Statement statement) { | 4650 void set body(Statement statement) { |
| 5426 _body = _becomeParentOf(statement); | 4651 _body = _becomeParentOf(statement); |
| 5427 } | 4652 } |
| 5428 | 4653 |
| 5429 @override | 4654 @override |
| 5430 Iterable get childEntities => new ChildEntities() | 4655 Iterable get childEntities => new ChildEntities() |
| 5431 ..add(forKeyword) | 4656 ..add(forKeyword) |
| 5432 ..add(leftParenthesis) | 4657 ..add(leftParenthesis) |
| 5433 ..add(_variableList) | 4658 ..add(_variableList) |
| 5434 ..add(_initialization) | 4659 ..add(_initialization) |
| 5435 ..add(leftSeparator) | 4660 ..add(leftSeparator) |
| 5436 ..add(_condition) | 4661 ..add(_condition) |
| 5437 ..add(rightSeparator) | 4662 ..add(rightSeparator) |
| 5438 ..addAll(_updaters) | 4663 ..addAll(_updaters) |
| 5439 ..add(rightParenthesis) | 4664 ..add(rightParenthesis) |
| 5440 ..add(_body); | 4665 ..add(_body); |
| 5441 | 4666 |
| 5442 /** | 4667 @override |
| 5443 * Return the condition used to determine when to terminate the loop, or | |
| 5444 * `null` if there is no condition. | |
| 5445 */ | |
| 5446 Expression get condition => _condition; | 4668 Expression get condition => _condition; |
| 5447 | 4669 |
| 5448 /** | 4670 @override |
| 5449 * Set the condition used to determine when to terminate the loop to the given | |
| 5450 * [expression]. | |
| 5451 */ | |
| 5452 void set condition(Expression expression) { | 4671 void set condition(Expression expression) { |
| 5453 _condition = _becomeParentOf(expression); | 4672 _condition = _becomeParentOf(expression); |
| 5454 } | 4673 } |
| 5455 | 4674 |
| 5456 @override | 4675 @override |
| 5457 Token get endToken => _body.endToken; | 4676 Token get endToken => _body.endToken; |
| 5458 | 4677 |
| 5459 /** | 4678 @override |
| 5460 * Return the initialization expression, or `null` if there is no | |
| 5461 * initialization expression. | |
| 5462 */ | |
| 5463 Expression get initialization => _initialization; | 4679 Expression get initialization => _initialization; |
| 5464 | 4680 |
| 5465 /** | 4681 @override |
| 5466 * Set the initialization expression to the given [expression]. | |
| 5467 */ | |
| 5468 void set initialization(Expression initialization) { | 4682 void set initialization(Expression initialization) { |
| 5469 _initialization = _becomeParentOf(initialization); | 4683 _initialization = _becomeParentOf(initialization); |
| 5470 } | 4684 } |
| 5471 | 4685 |
| 5472 /** | 4686 @override |
| 5473 * Return the list of expressions run after each execution of the loop body. | |
| 5474 */ | |
| 5475 NodeList<Expression> get updaters => _updaters; | 4687 NodeList<Expression> get updaters => _updaters; |
| 5476 | 4688 |
| 5477 /** | 4689 @override |
| 5478 * Return the declaration of the loop variables, or `null` if there are no | |
| 5479 * variables. | |
| 5480 */ | |
| 5481 VariableDeclarationList get variables => _variableList; | 4690 VariableDeclarationList get variables => _variableList; |
| 5482 | 4691 |
| 5483 /** | 4692 @override |
| 5484 * Set the declaration of the loop variables to the given [variableList]. | |
| 5485 */ | |
| 5486 void set variables(VariableDeclarationList variableList) { | 4693 void set variables(VariableDeclarationList variableList) { |
| 5487 _variableList = _becomeParentOf(variableList); | 4694 _variableList = _becomeParentOf(variableList); |
| 5488 } | 4695 } |
| 5489 | 4696 |
| 5490 @override | 4697 @override |
| 5491 accept(AstVisitor visitor) => visitor.visitForStatement(this); | 4698 accept(AstVisitor visitor) => visitor.visitForStatement(this); |
| 5492 | 4699 |
| 5493 @override | 4700 @override |
| 5494 void visitChildren(AstVisitor visitor) { | 4701 void visitChildren(AstVisitor visitor) { |
| 5495 _safelyVisitChild(_variableList, visitor); | 4702 _safelyVisitChild(_variableList, visitor); |
| 5496 _safelyVisitChild(_initialization, visitor); | 4703 _safelyVisitChild(_initialization, visitor); |
| 5497 _safelyVisitChild(_condition, visitor); | 4704 _safelyVisitChild(_condition, visitor); |
| 5498 _updaters.accept(visitor); | 4705 _updaters.accept(visitor); |
| 5499 _safelyVisitChild(_body, visitor); | 4706 _safelyVisitChild(_body, visitor); |
| 5500 } | 4707 } |
| 5501 } | 4708 } |
| 5502 | 4709 |
| 5503 /** | 4710 /** |
| 5504 * A node representing the body of a function or method. | 4711 * A node representing the body of a function or method. |
| 5505 * | 4712 * |
| 5506 * > functionBody ::= | 4713 * > functionBody ::= |
| 5507 * > [BlockFunctionBody] | 4714 * > [BlockFunctionBody] |
| 5508 * > | [EmptyFunctionBody] | 4715 * > | [EmptyFunctionBody] |
| 5509 * > | [ExpressionFunctionBody] | 4716 * > | [ExpressionFunctionBody] |
| 5510 */ | 4717 */ |
| 5511 abstract class FunctionBody extends AstNode { | 4718 abstract class FunctionBodyImpl extends AstNodeImpl implements FunctionBody { |
| 5512 /** | 4719 /** |
| 5513 * Return `true` if this function body is asynchronous. | 4720 * Return `true` if this function body is asynchronous. |
| 5514 */ | 4721 */ |
| 5515 bool get isAsynchronous => false; | 4722 bool get isAsynchronous => false; |
| 5516 | 4723 |
| 5517 /** | 4724 /** |
| 5518 * Return `true` if this function body is a generator. | 4725 * Return `true` if this function body is a generator. |
| 5519 */ | 4726 */ |
| 5520 bool get isGenerator => false; | 4727 bool get isGenerator => false; |
| 5521 | 4728 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5540 /** | 4747 /** |
| 5541 * A top-level declaration. | 4748 * A top-level declaration. |
| 5542 * | 4749 * |
| 5543 * > functionDeclaration ::= | 4750 * > functionDeclaration ::= |
| 5544 * > 'external' functionSignature | 4751 * > 'external' functionSignature |
| 5545 * > | functionSignature [FunctionBody] | 4752 * > | functionSignature [FunctionBody] |
| 5546 * > | 4753 * > |
| 5547 * > functionSignature ::= | 4754 * > functionSignature ::= |
| 5548 * > [Type]? ('get' | 'set')? [SimpleIdentifier] [FormalParameterList] | 4755 * > [Type]? ('get' | 'set')? [SimpleIdentifier] [FormalParameterList] |
| 5549 */ | 4756 */ |
| 5550 class FunctionDeclaration extends NamedCompilationUnitMember { | 4757 class FunctionDeclarationImpl extends NamedCompilationUnitMemberImpl |
| 4758 implements FunctionDeclaration { |
| 5551 /** | 4759 /** |
| 5552 * The token representing the 'external' keyword, or `null` if this is not an | 4760 * The token representing the 'external' keyword, or `null` if this is not an |
| 5553 * external function. | 4761 * external function. |
| 5554 */ | 4762 */ |
| 5555 Token externalKeyword; | 4763 Token externalKeyword; |
| 5556 | 4764 |
| 5557 /** | 4765 /** |
| 5558 * The return type of the function, or `null` if no return type was declared. | 4766 * The return type of the function, or `null` if no return type was declared. |
| 5559 */ | 4767 */ |
| 5560 TypeName _returnType; | 4768 TypeName _returnType; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5571 FunctionExpression _functionExpression; | 4779 FunctionExpression _functionExpression; |
| 5572 | 4780 |
| 5573 /** | 4781 /** |
| 5574 * Initialize a newly created function declaration. Either or both of the | 4782 * Initialize a newly created function declaration. Either or both of the |
| 5575 * [comment] and [metadata] can be `null` if the function does not have the | 4783 * [comment] and [metadata] can be `null` if the function does not have the |
| 5576 * corresponding attribute. The [externalKeyword] can be `null` if the | 4784 * corresponding attribute. The [externalKeyword] can be `null` if the |
| 5577 * function is not an external function. The [returnType] can be `null` if no | 4785 * function is not an external function. The [returnType] can be `null` if no |
| 5578 * return type was specified. The [propertyKeyword] can be `null` if the | 4786 * return type was specified. The [propertyKeyword] can be `null` if the |
| 5579 * function is neither a getter or a setter. | 4787 * function is neither a getter or a setter. |
| 5580 */ | 4788 */ |
| 5581 FunctionDeclaration( | 4789 FunctionDeclarationImpl( |
| 5582 Comment comment, | 4790 Comment comment, |
| 5583 List<Annotation> metadata, | 4791 List<Annotation> metadata, |
| 5584 this.externalKeyword, | 4792 this.externalKeyword, |
| 5585 TypeName returnType, | 4793 TypeName returnType, |
| 5586 this.propertyKeyword, | 4794 this.propertyKeyword, |
| 5587 SimpleIdentifier name, | 4795 SimpleIdentifier name, |
| 5588 FunctionExpression functionExpression) | 4796 FunctionExpression functionExpression) |
| 5589 : super(comment, metadata, name) { | 4797 : super(comment, metadata, name) { |
| 5590 _returnType = _becomeParentOf(returnType); | 4798 _returnType = _becomeParentOf(returnType); |
| 5591 _functionExpression = _becomeParentOf(functionExpression); | 4799 _functionExpression = _becomeParentOf(functionExpression); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5613 } else if (_returnType != null) { | 4821 } else if (_returnType != null) { |
| 5614 return _returnType.beginToken; | 4822 return _returnType.beginToken; |
| 5615 } else if (propertyKeyword != null) { | 4823 } else if (propertyKeyword != null) { |
| 5616 return propertyKeyword; | 4824 return propertyKeyword; |
| 5617 } else if (_name != null) { | 4825 } else if (_name != null) { |
| 5618 return _name.beginToken; | 4826 return _name.beginToken; |
| 5619 } | 4827 } |
| 5620 return _functionExpression.beginToken; | 4828 return _functionExpression.beginToken; |
| 5621 } | 4829 } |
| 5622 | 4830 |
| 5623 /** | 4831 @override |
| 5624 * Return the function expression being wrapped. | |
| 5625 */ | |
| 5626 FunctionExpression get functionExpression => _functionExpression; | 4832 FunctionExpression get functionExpression => _functionExpression; |
| 5627 | 4833 |
| 5628 /** | 4834 @override |
| 5629 * Set the function expression being wrapped to the given | |
| 5630 * [functionExpression]. | |
| 5631 */ | |
| 5632 void set functionExpression(FunctionExpression functionExpression) { | 4835 void set functionExpression(FunctionExpression functionExpression) { |
| 5633 _functionExpression = _becomeParentOf(functionExpression); | 4836 _functionExpression = _becomeParentOf(functionExpression); |
| 5634 } | 4837 } |
| 5635 | 4838 |
| 5636 /** | 4839 @override |
| 5637 * Return `true` if this function declares a getter. | |
| 5638 */ | |
| 5639 bool get isGetter => | 4840 bool get isGetter => |
| 5640 propertyKeyword != null && | 4841 propertyKeyword != null && |
| 5641 (propertyKeyword as KeywordToken).keyword == Keyword.GET; | 4842 (propertyKeyword as KeywordToken).keyword == Keyword.GET; |
| 5642 | 4843 |
| 5643 /** | 4844 @override |
| 5644 * Return `true` if this function declares a setter. | |
| 5645 */ | |
| 5646 bool get isSetter => | 4845 bool get isSetter => |
| 5647 propertyKeyword != null && | 4846 propertyKeyword != null && |
| 5648 (propertyKeyword as KeywordToken).keyword == Keyword.SET; | 4847 (propertyKeyword as KeywordToken).keyword == Keyword.SET; |
| 5649 | 4848 |
| 5650 /** | 4849 @override |
| 5651 * Return the return type of the function, or `null` if no return type was | |
| 5652 * declared. | |
| 5653 */ | |
| 5654 TypeName get returnType => _returnType; | 4850 TypeName get returnType => _returnType; |
| 5655 | 4851 |
| 5656 /** | 4852 @override |
| 5657 * Set the return type of the function to the given [returnType]. | |
| 5658 */ | |
| 5659 void set returnType(TypeName returnType) { | 4853 void set returnType(TypeName returnType) { |
| 5660 _returnType = _becomeParentOf(returnType); | 4854 _returnType = _becomeParentOf(returnType); |
| 5661 } | 4855 } |
| 5662 | 4856 |
| 5663 @override | 4857 @override |
| 5664 accept(AstVisitor visitor) => visitor.visitFunctionDeclaration(this); | 4858 accept(AstVisitor visitor) => visitor.visitFunctionDeclaration(this); |
| 5665 | 4859 |
| 5666 @override | 4860 @override |
| 5667 void visitChildren(AstVisitor visitor) { | 4861 void visitChildren(AstVisitor visitor) { |
| 5668 super.visitChildren(visitor); | 4862 super.visitChildren(visitor); |
| 5669 _safelyVisitChild(_returnType, visitor); | 4863 _safelyVisitChild(_returnType, visitor); |
| 5670 _safelyVisitChild(_name, visitor); | 4864 _safelyVisitChild(_name, visitor); |
| 5671 _safelyVisitChild(_functionExpression, visitor); | 4865 _safelyVisitChild(_functionExpression, visitor); |
| 5672 } | 4866 } |
| 5673 } | 4867 } |
| 5674 | 4868 |
| 5675 /** | 4869 /** |
| 5676 * A [FunctionDeclaration] used as a statement. | 4870 * A [FunctionDeclaration] used as a statement. |
| 5677 */ | 4871 */ |
| 5678 class FunctionDeclarationStatement extends Statement { | 4872 class FunctionDeclarationStatementImpl extends StatementImpl |
| 4873 implements FunctionDeclarationStatement { |
| 5679 /** | 4874 /** |
| 5680 * The function declaration being wrapped. | 4875 * The function declaration being wrapped. |
| 5681 */ | 4876 */ |
| 5682 FunctionDeclaration _functionDeclaration; | 4877 FunctionDeclaration _functionDeclaration; |
| 5683 | 4878 |
| 5684 /** | 4879 /** |
| 5685 * Initialize a newly created function declaration statement. | 4880 * Initialize a newly created function declaration statement. |
| 5686 */ | 4881 */ |
| 5687 FunctionDeclarationStatement(FunctionDeclaration functionDeclaration) { | 4882 FunctionDeclarationStatementImpl(FunctionDeclaration functionDeclaration) { |
| 5688 _functionDeclaration = _becomeParentOf(functionDeclaration); | 4883 _functionDeclaration = _becomeParentOf(functionDeclaration); |
| 5689 } | 4884 } |
| 5690 | 4885 |
| 5691 @override | 4886 @override |
| 5692 Token get beginToken => _functionDeclaration.beginToken; | 4887 Token get beginToken => _functionDeclaration.beginToken; |
| 5693 | 4888 |
| 5694 @override | 4889 @override |
| 5695 Iterable get childEntities => new ChildEntities()..add(_functionDeclaration); | 4890 Iterable get childEntities => new ChildEntities()..add(_functionDeclaration); |
| 5696 | 4891 |
| 5697 @override | 4892 @override |
| 5698 Token get endToken => _functionDeclaration.endToken; | 4893 Token get endToken => _functionDeclaration.endToken; |
| 5699 | 4894 |
| 5700 /** | 4895 @override |
| 5701 * Return the function declaration being wrapped. | |
| 5702 */ | |
| 5703 FunctionDeclaration get functionDeclaration => _functionDeclaration; | 4896 FunctionDeclaration get functionDeclaration => _functionDeclaration; |
| 5704 | 4897 |
| 5705 /** | 4898 @override |
| 5706 * Set the function declaration being wrapped to the given | |
| 5707 * [functionDeclaration]. | |
| 5708 */ | |
| 5709 void set functionDeclaration(FunctionDeclaration functionDeclaration) { | 4899 void set functionDeclaration(FunctionDeclaration functionDeclaration) { |
| 5710 _functionDeclaration = _becomeParentOf(functionDeclaration); | 4900 _functionDeclaration = _becomeParentOf(functionDeclaration); |
| 5711 } | 4901 } |
| 5712 | 4902 |
| 5713 @override | 4903 @override |
| 5714 accept(AstVisitor visitor) => visitor.visitFunctionDeclarationStatement(this); | 4904 accept(AstVisitor visitor) => visitor.visitFunctionDeclarationStatement(this); |
| 5715 | 4905 |
| 5716 @override | 4906 @override |
| 5717 void visitChildren(AstVisitor visitor) { | 4907 void visitChildren(AstVisitor visitor) { |
| 5718 _safelyVisitChild(_functionDeclaration, visitor); | 4908 _safelyVisitChild(_functionDeclaration, visitor); |
| 5719 } | 4909 } |
| 5720 } | 4910 } |
| 5721 | 4911 |
| 5722 /** | 4912 /** |
| 5723 * A function expression. | 4913 * A function expression. |
| 5724 * | 4914 * |
| 5725 * > functionExpression ::= | 4915 * > functionExpression ::= |
| 5726 * > [TypeParameterList]? [FormalParameterList] [FunctionBody] | 4916 * > [TypeParameterList]? [FormalParameterList] [FunctionBody] |
| 5727 */ | 4917 */ |
| 5728 class FunctionExpression extends Expression { | 4918 class FunctionExpressionImpl extends ExpressionImpl |
| 4919 implements FunctionExpression { |
| 5729 /** | 4920 /** |
| 5730 * The type parameters associated with the method, or `null` if the method is | 4921 * The type parameters associated with the method, or `null` if the method is |
| 5731 * not a generic method. | 4922 * not a generic method. |
| 5732 */ | 4923 */ |
| 5733 TypeParameterList _typeParameters; | 4924 TypeParameterList _typeParameters; |
| 5734 | 4925 |
| 5735 /** | 4926 /** |
| 5736 * The parameters associated with the function. | 4927 * The parameters associated with the function. |
| 5737 */ | 4928 */ |
| 5738 FormalParameterList _parameters; | 4929 FormalParameterList _parameters; |
| 5739 | 4930 |
| 5740 /** | 4931 /** |
| 5741 * The body of the function, or `null` if this is an external function. | 4932 * The body of the function, or `null` if this is an external function. |
| 5742 */ | 4933 */ |
| 5743 FunctionBody _body; | 4934 FunctionBody _body; |
| 5744 | 4935 |
| 5745 /** | 4936 /** |
| 5746 * The element associated with the function, or `null` if the AST structure | 4937 * The element associated with the function, or `null` if the AST structure |
| 5747 * has not been resolved. | 4938 * has not been resolved. |
| 5748 */ | 4939 */ |
| 5749 ExecutableElement element; | 4940 ExecutableElement element; |
| 5750 | 4941 |
| 5751 /** | 4942 /** |
| 5752 * Initialize a newly created function declaration. | 4943 * Initialize a newly created function declaration. |
| 5753 */ | 4944 */ |
| 5754 FunctionExpression(TypeParameterList typeParameters, | 4945 FunctionExpressionImpl(TypeParameterList typeParameters, |
| 5755 FormalParameterList parameters, FunctionBody body) { | 4946 FormalParameterList parameters, FunctionBody body) { |
| 5756 _typeParameters = _becomeParentOf(typeParameters); | 4947 _typeParameters = _becomeParentOf(typeParameters); |
| 5757 _parameters = _becomeParentOf(parameters); | 4948 _parameters = _becomeParentOf(parameters); |
| 5758 _body = _becomeParentOf(body); | 4949 _body = _becomeParentOf(body); |
| 5759 } | 4950 } |
| 5760 | 4951 |
| 5761 @override | 4952 @override |
| 5762 Token get beginToken { | 4953 Token get beginToken { |
| 5763 if (_typeParameters != null) { | 4954 if (_typeParameters != null) { |
| 5764 return _typeParameters.beginToken; | 4955 return _typeParameters.beginToken; |
| 5765 } else if (_parameters != null) { | 4956 } else if (_parameters != null) { |
| 5766 return _parameters.beginToken; | 4957 return _parameters.beginToken; |
| 5767 } else if (_body != null) { | 4958 } else if (_body != null) { |
| 5768 return _body.beginToken; | 4959 return _body.beginToken; |
| 5769 } | 4960 } |
| 5770 // This should never be reached because external functions must be named, | 4961 // This should never be reached because external functions must be named, |
| 5771 // hence either the body or the name should be non-null. | 4962 // hence either the body or the name should be non-null. |
| 5772 throw new IllegalStateException("Non-external functions must have a body"); | 4963 throw new IllegalStateException("Non-external functions must have a body"); |
| 5773 } | 4964 } |
| 5774 | 4965 |
| 5775 /** | 4966 @override |
| 5776 * Return the body of the function, or `null` if this is an external function. | |
| 5777 */ | |
| 5778 FunctionBody get body => _body; | 4967 FunctionBody get body => _body; |
| 5779 | 4968 |
| 5780 /** | 4969 @override |
| 5781 * Set the body of the function to the given [functionBody]. | |
| 5782 */ | |
| 5783 void set body(FunctionBody functionBody) { | 4970 void set body(FunctionBody functionBody) { |
| 5784 _body = _becomeParentOf(functionBody); | 4971 _body = _becomeParentOf(functionBody); |
| 5785 } | 4972 } |
| 5786 | 4973 |
| 5787 @override | 4974 @override |
| 5788 Iterable get childEntities => | 4975 Iterable get childEntities => |
| 5789 new ChildEntities()..add(_parameters)..add(_body); | 4976 new ChildEntities()..add(_parameters)..add(_body); |
| 5790 | 4977 |
| 5791 @override | 4978 @override |
| 5792 Token get endToken { | 4979 Token get endToken { |
| 5793 if (_body != null) { | 4980 if (_body != null) { |
| 5794 return _body.endToken; | 4981 return _body.endToken; |
| 5795 } else if (_parameters != null) { | 4982 } else if (_parameters != null) { |
| 5796 return _parameters.endToken; | 4983 return _parameters.endToken; |
| 5797 } | 4984 } |
| 5798 // This should never be reached because external functions must be named, | 4985 // This should never be reached because external functions must be named, |
| 5799 // hence either the body or the name should be non-null. | 4986 // hence either the body or the name should be non-null. |
| 5800 throw new IllegalStateException("Non-external functions must have a body"); | 4987 throw new IllegalStateException("Non-external functions must have a body"); |
| 5801 } | 4988 } |
| 5802 | 4989 |
| 5803 /** | 4990 @override |
| 5804 * Return the parameters associated with the function. | |
| 5805 */ | |
| 5806 FormalParameterList get parameters => _parameters; | 4991 FormalParameterList get parameters => _parameters; |
| 5807 | 4992 |
| 5808 /** | 4993 @override |
| 5809 * Set the parameters associated with the function to the given list of | |
| 5810 * [parameters]. | |
| 5811 */ | |
| 5812 void set parameters(FormalParameterList parameters) { | 4994 void set parameters(FormalParameterList parameters) { |
| 5813 _parameters = _becomeParentOf(parameters); | 4995 _parameters = _becomeParentOf(parameters); |
| 5814 } | 4996 } |
| 5815 | 4997 |
| 5816 @override | 4998 @override |
| 5817 int get precedence => 16; | 4999 int get precedence => 16; |
| 5818 | 5000 |
| 5819 /** | 5001 @override |
| 5820 * Return the type parameters associated with this method, or `null` if this | |
| 5821 * method is not a generic method. | |
| 5822 */ | |
| 5823 TypeParameterList get typeParameters => _typeParameters; | 5002 TypeParameterList get typeParameters => _typeParameters; |
| 5824 | 5003 |
| 5825 /** | 5004 @override |
| 5826 * Set the type parameters associated with this method to the given | |
| 5827 * [typeParameters]. | |
| 5828 */ | |
| 5829 void set typeParameters(TypeParameterList typeParameters) { | 5005 void set typeParameters(TypeParameterList typeParameters) { |
| 5830 _typeParameters = _becomeParentOf(typeParameters); | 5006 _typeParameters = _becomeParentOf(typeParameters); |
| 5831 } | 5007 } |
| 5832 | 5008 |
| 5833 @override | 5009 @override |
| 5834 accept(AstVisitor visitor) => visitor.visitFunctionExpression(this); | 5010 accept(AstVisitor visitor) => visitor.visitFunctionExpression(this); |
| 5835 | 5011 |
| 5836 @override | 5012 @override |
| 5837 void visitChildren(AstVisitor visitor) { | 5013 void visitChildren(AstVisitor visitor) { |
| 5838 _safelyVisitChild(_typeParameters, visitor); | 5014 _safelyVisitChild(_typeParameters, visitor); |
| 5839 _safelyVisitChild(_parameters, visitor); | 5015 _safelyVisitChild(_parameters, visitor); |
| 5840 _safelyVisitChild(_body, visitor); | 5016 _safelyVisitChild(_body, visitor); |
| 5841 } | 5017 } |
| 5842 } | 5018 } |
| 5843 | 5019 |
| 5844 /** | 5020 /** |
| 5845 * The invocation of a function resulting from evaluating an expression. | 5021 * The invocation of a function resulting from evaluating an expression. |
| 5846 * Invocations of methods and other forms of functions are represented by | 5022 * Invocations of methods and other forms of functions are represented by |
| 5847 * [MethodInvocation] nodes. Invocations of getters and setters are represented | 5023 * [MethodInvocation] nodes. Invocations of getters and setters are represented |
| 5848 * by either [PrefixedIdentifier] or [PropertyAccess] nodes. | 5024 * by either [PrefixedIdentifier] or [PropertyAccess] nodes. |
| 5849 * | 5025 * |
| 5850 * > functionExpressionInvocation ::= | 5026 * > functionExpressionInvocation ::= |
| 5851 * > [Expression] [TypeArgumentList]? [ArgumentList] | 5027 * > [Expression] [TypeArgumentList]? [ArgumentList] |
| 5852 */ | 5028 */ |
| 5853 class FunctionExpressionInvocation extends Expression { | 5029 class FunctionExpressionInvocationImpl extends ExpressionImpl |
| 5030 implements FunctionExpressionInvocation { |
| 5854 /** | 5031 /** |
| 5855 * The expression producing the function being invoked. | 5032 * The expression producing the function being invoked. |
| 5856 */ | 5033 */ |
| 5857 Expression _function; | 5034 Expression _function; |
| 5858 | 5035 |
| 5859 /** | 5036 /** |
| 5860 * The type arguments to be applied to the method being invoked, or `null` if | 5037 * The type arguments to be applied to the method being invoked, or `null` if |
| 5861 * no type arguments were provided. | 5038 * no type arguments were provided. |
| 5862 */ | 5039 */ |
| 5863 TypeArgumentList _typeArguments; | 5040 TypeArgumentList _typeArguments; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5892 ExecutableElement propagatedElement; | 5069 ExecutableElement propagatedElement; |
| 5893 | 5070 |
| 5894 /** | 5071 /** |
| 5895 * Like [staticInvokeType], but reflects propagated type information. | 5072 * Like [staticInvokeType], but reflects propagated type information. |
| 5896 */ | 5073 */ |
| 5897 DartType propagatedInvokeType; | 5074 DartType propagatedInvokeType; |
| 5898 | 5075 |
| 5899 /** | 5076 /** |
| 5900 * Initialize a newly created function expression invocation. | 5077 * Initialize a newly created function expression invocation. |
| 5901 */ | 5078 */ |
| 5902 FunctionExpressionInvocation(Expression function, | 5079 FunctionExpressionInvocationImpl(Expression function, |
| 5903 TypeArgumentList typeArguments, ArgumentList argumentList) { | 5080 TypeArgumentList typeArguments, ArgumentList argumentList) { |
| 5904 _function = _becomeParentOf(function); | 5081 _function = _becomeParentOf(function); |
| 5905 _typeArguments = _becomeParentOf(typeArguments); | 5082 _typeArguments = _becomeParentOf(typeArguments); |
| 5906 _argumentList = _becomeParentOf(argumentList); | 5083 _argumentList = _becomeParentOf(argumentList); |
| 5907 } | 5084 } |
| 5908 | 5085 |
| 5909 /** | 5086 @override |
| 5910 * Return the list of arguments to the method. | |
| 5911 */ | |
| 5912 ArgumentList get argumentList => _argumentList; | 5087 ArgumentList get argumentList => _argumentList; |
| 5913 | 5088 |
| 5914 /** | 5089 @override |
| 5915 * Set the list of arguments to the method to the given [argumentList]. | |
| 5916 */ | |
| 5917 void set argumentList(ArgumentList argumentList) { | 5090 void set argumentList(ArgumentList argumentList) { |
| 5918 _argumentList = _becomeParentOf(argumentList); | 5091 _argumentList = _becomeParentOf(argumentList); |
| 5919 } | 5092 } |
| 5920 | 5093 |
| 5921 @override | 5094 @override |
| 5922 Token get beginToken => _function.beginToken; | 5095 Token get beginToken => _function.beginToken; |
| 5923 | 5096 |
| 5924 /** | 5097 @override |
| 5925 * Return the best element available for the function being invoked. If | |
| 5926 * resolution was able to find a better element based on type propagation, | |
| 5927 * that element will be returned. Otherwise, the element found using the | |
| 5928 * result of static analysis will be returned. If resolution has not been | |
| 5929 * performed, then `null` will be returned. | |
| 5930 */ | |
| 5931 ExecutableElement get bestElement { | 5098 ExecutableElement get bestElement { |
| 5932 ExecutableElement element = propagatedElement; | 5099 ExecutableElement element = propagatedElement; |
| 5933 if (element == null) { | 5100 if (element == null) { |
| 5934 element = staticElement; | 5101 element = staticElement; |
| 5935 } | 5102 } |
| 5936 return element; | 5103 return element; |
| 5937 } | 5104 } |
| 5938 | 5105 |
| 5939 @override | 5106 @override |
| 5940 Iterable get childEntities => | 5107 Iterable get childEntities => |
| 5941 new ChildEntities()..add(_function)..add(_argumentList); | 5108 new ChildEntities()..add(_function)..add(_argumentList); |
| 5942 | 5109 |
| 5943 @override | 5110 @override |
| 5944 Token get endToken => _argumentList.endToken; | 5111 Token get endToken => _argumentList.endToken; |
| 5945 | 5112 |
| 5946 /** | 5113 @override |
| 5947 * Return the expression producing the function being invoked. | |
| 5948 */ | |
| 5949 Expression get function => _function; | 5114 Expression get function => _function; |
| 5950 | 5115 |
| 5951 /** | 5116 @override |
| 5952 * Set the expression producing the function being invoked to the given | |
| 5953 * [expression]. | |
| 5954 */ | |
| 5955 void set function(Expression expression) { | 5117 void set function(Expression expression) { |
| 5956 _function = _becomeParentOf(expression); | 5118 _function = _becomeParentOf(expression); |
| 5957 } | 5119 } |
| 5958 | 5120 |
| 5959 @override | 5121 @override |
| 5960 int get precedence => 15; | 5122 int get precedence => 15; |
| 5961 | 5123 |
| 5962 /** | 5124 @override |
| 5963 * Return the type arguments to be applied to the method being invoked, or | |
| 5964 * `null` if no type arguments were provided. | |
| 5965 */ | |
| 5966 TypeArgumentList get typeArguments => _typeArguments; | 5125 TypeArgumentList get typeArguments => _typeArguments; |
| 5967 | 5126 |
| 5968 /** | 5127 @override |
| 5969 * Set the type arguments to be applied to the method being invoked to the | |
| 5970 * given [typeArguments]. | |
| 5971 */ | |
| 5972 void set typeArguments(TypeArgumentList typeArguments) { | 5128 void set typeArguments(TypeArgumentList typeArguments) { |
| 5973 _typeArguments = _becomeParentOf(typeArguments); | 5129 _typeArguments = _becomeParentOf(typeArguments); |
| 5974 } | 5130 } |
| 5975 | 5131 |
| 5976 @override | 5132 @override |
| 5977 accept(AstVisitor visitor) => visitor.visitFunctionExpressionInvocation(this); | 5133 accept(AstVisitor visitor) => visitor.visitFunctionExpressionInvocation(this); |
| 5978 | 5134 |
| 5979 @override | 5135 @override |
| 5980 void visitChildren(AstVisitor visitor) { | 5136 void visitChildren(AstVisitor visitor) { |
| 5981 _safelyVisitChild(_function, visitor); | 5137 _safelyVisitChild(_function, visitor); |
| 5982 _safelyVisitChild(_typeArguments, visitor); | 5138 _safelyVisitChild(_typeArguments, visitor); |
| 5983 _safelyVisitChild(_argumentList, visitor); | 5139 _safelyVisitChild(_argumentList, visitor); |
| 5984 } | 5140 } |
| 5985 } | 5141 } |
| 5986 | 5142 |
| 5987 /** | 5143 /** |
| 5988 * A function type alias. | 5144 * A function type alias. |
| 5989 * | 5145 * |
| 5990 * > functionTypeAlias ::= | 5146 * > functionTypeAlias ::= |
| 5991 * > functionPrefix [TypeParameterList]? [FormalParameterList] ';' | 5147 * > functionPrefix [TypeParameterList]? [FormalParameterList] ';' |
| 5992 * > | 5148 * > |
| 5993 * > functionPrefix ::= | 5149 * > functionPrefix ::= |
| 5994 * > [TypeName]? [SimpleIdentifier] | 5150 * > [TypeName]? [SimpleIdentifier] |
| 5995 */ | 5151 */ |
| 5996 class FunctionTypeAlias extends TypeAlias { | 5152 class FunctionTypeAliasImpl extends TypeAliasImpl implements FunctionTypeAlias { |
| 5997 /** | 5153 /** |
| 5998 * The name of the return type of the function type being defined, or `null` | 5154 * The name of the return type of the function type being defined, or `null` |
| 5999 * if no return type was given. | 5155 * if no return type was given. |
| 6000 */ | 5156 */ |
| 6001 TypeName _returnType; | 5157 TypeName _returnType; |
| 6002 | 5158 |
| 6003 /** | 5159 /** |
| 6004 * The type parameters for the function type, or `null` if the function type | 5160 * The type parameters for the function type, or `null` if the function type |
| 6005 * does not have any type parameters. | 5161 * does not have any type parameters. |
| 6006 */ | 5162 */ |
| 6007 TypeParameterList _typeParameters; | 5163 TypeParameterList _typeParameters; |
| 6008 | 5164 |
| 6009 /** | 5165 /** |
| 6010 * The parameters associated with the function type. | 5166 * The parameters associated with the function type. |
| 6011 */ | 5167 */ |
| 6012 FormalParameterList _parameters; | 5168 FormalParameterList _parameters; |
| 6013 | 5169 |
| 6014 /** | 5170 /** |
| 6015 * Initialize a newly created function type alias. Either or both of the | 5171 * Initialize a newly created function type alias. Either or both of the |
| 6016 * [comment] and [metadata] can be `null` if the function does not have the | 5172 * [comment] and [metadata] can be `null` if the function does not have the |
| 6017 * corresponding attribute. The [returnType] can be `null` if no return type | 5173 * corresponding attribute. The [returnType] can be `null` if no return type |
| 6018 * was specified. The [typeParameters] can be `null` if the function has no | 5174 * was specified. The [typeParameters] can be `null` if the function has no |
| 6019 * type parameters. | 5175 * type parameters. |
| 6020 */ | 5176 */ |
| 6021 FunctionTypeAlias( | 5177 FunctionTypeAliasImpl( |
| 6022 Comment comment, | 5178 Comment comment, |
| 6023 List<Annotation> metadata, | 5179 List<Annotation> metadata, |
| 6024 Token keyword, | 5180 Token keyword, |
| 6025 TypeName returnType, | 5181 TypeName returnType, |
| 6026 SimpleIdentifier name, | 5182 SimpleIdentifier name, |
| 6027 TypeParameterList typeParameters, | 5183 TypeParameterList typeParameters, |
| 6028 FormalParameterList parameters, | 5184 FormalParameterList parameters, |
| 6029 Token semicolon) | 5185 Token semicolon) |
| 6030 : super(comment, metadata, keyword, name, semicolon) { | 5186 : super(comment, metadata, keyword, name, semicolon) { |
| 6031 _returnType = _becomeParentOf(returnType); | 5187 _returnType = _becomeParentOf(returnType); |
| 6032 _typeParameters = _becomeParentOf(typeParameters); | 5188 _typeParameters = _becomeParentOf(typeParameters); |
| 6033 _parameters = _becomeParentOf(parameters); | 5189 _parameters = _becomeParentOf(parameters); |
| 6034 } | 5190 } |
| 6035 | 5191 |
| 6036 @override | 5192 @override |
| 6037 Iterable get childEntities => super._childEntities | 5193 Iterable get childEntities => super._childEntities |
| 6038 ..add(typedefKeyword) | 5194 ..add(typedefKeyword) |
| 6039 ..add(_returnType) | 5195 ..add(_returnType) |
| 6040 ..add(_name) | 5196 ..add(_name) |
| 6041 ..add(_typeParameters) | 5197 ..add(_typeParameters) |
| 6042 ..add(_parameters) | 5198 ..add(_parameters) |
| 6043 ..add(semicolon); | 5199 ..add(semicolon); |
| 6044 | 5200 |
| 6045 @override | 5201 @override |
| 6046 FunctionTypeAliasElement get element => | 5202 FunctionTypeAliasElement get element => |
| 6047 _name != null ? (_name.staticElement as FunctionTypeAliasElement) : null; | 5203 _name != null ? (_name.staticElement as FunctionTypeAliasElement) : null; |
| 6048 | 5204 |
| 6049 /** | 5205 @override |
| 6050 * Return the parameters associated with the function type. | |
| 6051 */ | |
| 6052 FormalParameterList get parameters => _parameters; | 5206 FormalParameterList get parameters => _parameters; |
| 6053 | 5207 |
| 6054 /** | 5208 @override |
| 6055 * Set the parameters associated with the function type to the given list of | |
| 6056 * [parameters]. | |
| 6057 */ | |
| 6058 void set parameters(FormalParameterList parameters) { | 5209 void set parameters(FormalParameterList parameters) { |
| 6059 _parameters = _becomeParentOf(parameters); | 5210 _parameters = _becomeParentOf(parameters); |
| 6060 } | 5211 } |
| 6061 | 5212 |
| 6062 /** | 5213 @override |
| 6063 * Return the name of the return type of the function type being defined, or | |
| 6064 * `null` if no return type was given. | |
| 6065 */ | |
| 6066 TypeName get returnType => _returnType; | 5214 TypeName get returnType => _returnType; |
| 6067 | 5215 |
| 6068 /** | 5216 @override |
| 6069 * Set the name of the return type of the function type being defined to the | |
| 6070 * given [typeName]. | |
| 6071 */ | |
| 6072 void set returnType(TypeName typeName) { | 5217 void set returnType(TypeName typeName) { |
| 6073 _returnType = _becomeParentOf(typeName); | 5218 _returnType = _becomeParentOf(typeName); |
| 6074 } | 5219 } |
| 6075 | 5220 |
| 6076 /** | 5221 @override |
| 6077 * Return the type parameters for the function type, or `null` if the function | |
| 6078 * type does not have any type parameters. | |
| 6079 */ | |
| 6080 TypeParameterList get typeParameters => _typeParameters; | 5222 TypeParameterList get typeParameters => _typeParameters; |
| 6081 | 5223 |
| 6082 /** | 5224 @override |
| 6083 * Set the type parameters for the function type to the given list of | |
| 6084 * [typeParameters]. | |
| 6085 */ | |
| 6086 void set typeParameters(TypeParameterList typeParameters) { | 5225 void set typeParameters(TypeParameterList typeParameters) { |
| 6087 _typeParameters = _becomeParentOf(typeParameters); | 5226 _typeParameters = _becomeParentOf(typeParameters); |
| 6088 } | 5227 } |
| 6089 | 5228 |
| 6090 @override | 5229 @override |
| 6091 accept(AstVisitor visitor) => visitor.visitFunctionTypeAlias(this); | 5230 accept(AstVisitor visitor) => visitor.visitFunctionTypeAlias(this); |
| 6092 | 5231 |
| 6093 @override | 5232 @override |
| 6094 void visitChildren(AstVisitor visitor) { | 5233 void visitChildren(AstVisitor visitor) { |
| 6095 super.visitChildren(visitor); | 5234 super.visitChildren(visitor); |
| 6096 _safelyVisitChild(_returnType, visitor); | 5235 _safelyVisitChild(_returnType, visitor); |
| 6097 _safelyVisitChild(_name, visitor); | 5236 _safelyVisitChild(_name, visitor); |
| 6098 _safelyVisitChild(_typeParameters, visitor); | 5237 _safelyVisitChild(_typeParameters, visitor); |
| 6099 _safelyVisitChild(_parameters, visitor); | 5238 _safelyVisitChild(_parameters, visitor); |
| 6100 } | 5239 } |
| 6101 } | 5240 } |
| 6102 | 5241 |
| 6103 /** | 5242 /** |
| 6104 * A function-typed formal parameter. | 5243 * A function-typed formal parameter. |
| 6105 * | 5244 * |
| 6106 * > functionSignature ::= | 5245 * > functionSignature ::= |
| 6107 * > [TypeName]? [SimpleIdentifier] [TypeParameterList]? [FormalParameterLis
t] | 5246 * > [TypeName]? [SimpleIdentifier] [TypeParameterList]? [FormalParameterLis
t] |
| 6108 */ | 5247 */ |
| 6109 class FunctionTypedFormalParameter extends NormalFormalParameter { | 5248 class FunctionTypedFormalParameterImpl extends NormalFormalParameterImpl |
| 5249 implements FunctionTypedFormalParameter { |
| 6110 /** | 5250 /** |
| 6111 * The return type of the function, or `null` if the function does not have a | 5251 * The return type of the function, or `null` if the function does not have a |
| 6112 * return type. | 5252 * return type. |
| 6113 */ | 5253 */ |
| 6114 TypeName _returnType; | 5254 TypeName _returnType; |
| 6115 | 5255 |
| 6116 /** | 5256 /** |
| 6117 * The type parameters associated with the function, or `null` if the function | 5257 * The type parameters associated with the function, or `null` if the function |
| 6118 * is not a generic function. | 5258 * is not a generic function. |
| 6119 */ | 5259 */ |
| 6120 TypeParameterList _typeParameters; | 5260 TypeParameterList _typeParameters; |
| 6121 | 5261 |
| 6122 /** | 5262 /** |
| 6123 * The parameters of the function-typed parameter. | 5263 * The parameters of the function-typed parameter. |
| 6124 */ | 5264 */ |
| 6125 FormalParameterList _parameters; | 5265 FormalParameterList _parameters; |
| 6126 | 5266 |
| 6127 /** | 5267 /** |
| 6128 * Initialize a newly created formal parameter. Either or both of the | 5268 * Initialize a newly created formal parameter. Either or both of the |
| 6129 * [comment] and [metadata] can be `null` if the parameter does not have the | 5269 * [comment] and [metadata] can be `null` if the parameter does not have the |
| 6130 * corresponding attribute. The [returnType] can be `null` if no return type | 5270 * corresponding attribute. The [returnType] can be `null` if no return type |
| 6131 * was specified. | 5271 * was specified. |
| 6132 */ | 5272 */ |
| 6133 FunctionTypedFormalParameter( | 5273 FunctionTypedFormalParameterImpl( |
| 6134 Comment comment, | 5274 Comment comment, |
| 6135 List<Annotation> metadata, | 5275 List<Annotation> metadata, |
| 6136 TypeName returnType, | 5276 TypeName returnType, |
| 6137 SimpleIdentifier identifier, | 5277 SimpleIdentifier identifier, |
| 6138 TypeParameterList typeParameters, | 5278 TypeParameterList typeParameters, |
| 6139 FormalParameterList parameters) | 5279 FormalParameterList parameters) |
| 6140 : super(comment, metadata, identifier) { | 5280 : super(comment, metadata, identifier) { |
| 6141 _returnType = _becomeParentOf(returnType); | 5281 _returnType = _becomeParentOf(returnType); |
| 6142 _typeParameters = _becomeParentOf(typeParameters); | 5282 _typeParameters = _becomeParentOf(typeParameters); |
| 6143 _parameters = _becomeParentOf(parameters); | 5283 _parameters = _becomeParentOf(parameters); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6157 | 5297 |
| 6158 @override | 5298 @override |
| 6159 Token get endToken => _parameters.endToken; | 5299 Token get endToken => _parameters.endToken; |
| 6160 | 5300 |
| 6161 @override | 5301 @override |
| 6162 bool get isConst => false; | 5302 bool get isConst => false; |
| 6163 | 5303 |
| 6164 @override | 5304 @override |
| 6165 bool get isFinal => false; | 5305 bool get isFinal => false; |
| 6166 | 5306 |
| 6167 /** | 5307 @override |
| 6168 * Return the parameters of the function-typed parameter. | |
| 6169 */ | |
| 6170 FormalParameterList get parameters => _parameters; | 5308 FormalParameterList get parameters => _parameters; |
| 6171 | 5309 |
| 6172 /** | 5310 @override |
| 6173 * Set the parameters of the function-typed parameter to the given | |
| 6174 * [parameters]. | |
| 6175 */ | |
| 6176 void set parameters(FormalParameterList parameters) { | 5311 void set parameters(FormalParameterList parameters) { |
| 6177 _parameters = _becomeParentOf(parameters); | 5312 _parameters = _becomeParentOf(parameters); |
| 6178 } | 5313 } |
| 6179 | 5314 |
| 6180 /** | 5315 @override |
| 6181 * Return the return type of the function, or `null` if the function does not | |
| 6182 * have a return type. | |
| 6183 */ | |
| 6184 TypeName get returnType => _returnType; | 5316 TypeName get returnType => _returnType; |
| 6185 | 5317 |
| 6186 /** | 5318 @override |
| 6187 * Set the return type of the function to the given [type]. | |
| 6188 */ | |
| 6189 void set returnType(TypeName type) { | 5319 void set returnType(TypeName type) { |
| 6190 _returnType = _becomeParentOf(type); | 5320 _returnType = _becomeParentOf(type); |
| 6191 } | 5321 } |
| 6192 | 5322 |
| 6193 /** | 5323 @override |
| 6194 * Return the type parameters associated with this function, or `null` if | |
| 6195 * this function is not a generic function. | |
| 6196 */ | |
| 6197 TypeParameterList get typeParameters => _typeParameters; | 5324 TypeParameterList get typeParameters => _typeParameters; |
| 6198 | 5325 |
| 6199 /** | 5326 @override |
| 6200 * Set the type parameters associated with this method to the given | |
| 6201 * [typeParameters]. | |
| 6202 */ | |
| 6203 void set typeParameters(TypeParameterList typeParameters) { | 5327 void set typeParameters(TypeParameterList typeParameters) { |
| 6204 _typeParameters = _becomeParentOf(typeParameters); | 5328 _typeParameters = _becomeParentOf(typeParameters); |
| 6205 } | 5329 } |
| 6206 | 5330 |
| 6207 @override | 5331 @override |
| 6208 accept(AstVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this); | 5332 accept(AstVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this); |
| 6209 | 5333 |
| 6210 @override | 5334 @override |
| 6211 void visitChildren(AstVisitor visitor) { | 5335 void visitChildren(AstVisitor visitor) { |
| 6212 super.visitChildren(visitor); | 5336 super.visitChildren(visitor); |
| 6213 _safelyVisitChild(_returnType, visitor); | 5337 _safelyVisitChild(_returnType, visitor); |
| 6214 _safelyVisitChild(identifier, visitor); | 5338 _safelyVisitChild(identifier, visitor); |
| 6215 _safelyVisitChild(_typeParameters, visitor); | 5339 _safelyVisitChild(_typeParameters, visitor); |
| 6216 _safelyVisitChild(_parameters, visitor); | 5340 _safelyVisitChild(_parameters, visitor); |
| 6217 } | 5341 } |
| 6218 } | 5342 } |
| 6219 | 5343 |
| 6220 /** | 5344 /** |
| 6221 * A combinator that restricts the names being imported to those that are not in | 5345 * A combinator that restricts the names being imported to those that are not in |
| 6222 * a given list. | 5346 * a given list. |
| 6223 * | 5347 * |
| 6224 * > hideCombinator ::= | 5348 * > hideCombinator ::= |
| 6225 * > 'hide' [SimpleIdentifier] (',' [SimpleIdentifier])* | 5349 * > 'hide' [SimpleIdentifier] (',' [SimpleIdentifier])* |
| 6226 */ | 5350 */ |
| 6227 class HideCombinator extends Combinator { | 5351 class HideCombinatorImpl extends CombinatorImpl implements HideCombinator { |
| 6228 /** | 5352 /** |
| 6229 * The list of names from the library that are hidden by this combinator. | 5353 * The list of names from the library that are hidden by this combinator. |
| 6230 */ | 5354 */ |
| 6231 NodeList<SimpleIdentifier> _hiddenNames; | 5355 NodeList<SimpleIdentifier> _hiddenNames; |
| 6232 | 5356 |
| 6233 /** | 5357 /** |
| 6234 * Initialize a newly created import show combinator. | 5358 * Initialize a newly created import show combinator. |
| 6235 */ | 5359 */ |
| 6236 HideCombinator(Token keyword, List<SimpleIdentifier> hiddenNames) | 5360 HideCombinatorImpl(Token keyword, List<SimpleIdentifier> hiddenNames) |
| 6237 : super(keyword) { | 5361 : super(keyword) { |
| 6238 _hiddenNames = new NodeList<SimpleIdentifier>(this, hiddenNames); | 5362 _hiddenNames = new NodeList<SimpleIdentifier>(this, hiddenNames); |
| 6239 } | 5363 } |
| 6240 | 5364 |
| 6241 @override | 5365 @override |
| 6242 Iterable get childEntities => new ChildEntities() | 5366 Iterable get childEntities => new ChildEntities() |
| 6243 ..add(keyword) | 5367 ..add(keyword) |
| 6244 ..addAll(_hiddenNames); | 5368 ..addAll(_hiddenNames); |
| 6245 | 5369 |
| 6246 @override | 5370 @override |
| 6247 Token get endToken => _hiddenNames.endToken; | 5371 Token get endToken => _hiddenNames.endToken; |
| 6248 | 5372 |
| 6249 /** | 5373 @override |
| 6250 * Return the list of names from the library that are hidden by this | |
| 6251 * combinator. | |
| 6252 */ | |
| 6253 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames; | 5374 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames; |
| 6254 | 5375 |
| 6255 @override | 5376 @override |
| 6256 accept(AstVisitor visitor) => visitor.visitHideCombinator(this); | 5377 accept(AstVisitor visitor) => visitor.visitHideCombinator(this); |
| 6257 | 5378 |
| 6258 @override | 5379 @override |
| 6259 void visitChildren(AstVisitor visitor) { | 5380 void visitChildren(AstVisitor visitor) { |
| 6260 _hiddenNames.accept(visitor); | 5381 _hiddenNames.accept(visitor); |
| 6261 } | 5382 } |
| 6262 } | 5383 } |
| 6263 | 5384 |
| 6264 /** | 5385 /** |
| 6265 * A node that represents an identifier. | 5386 * A node that represents an identifier. |
| 6266 * | 5387 * |
| 6267 * > identifier ::= | 5388 * > identifier ::= |
| 6268 * > [SimpleIdentifier] | 5389 * > [SimpleIdentifier] |
| 6269 * > | [PrefixedIdentifier] | 5390 * > | [PrefixedIdentifier] |
| 6270 */ | 5391 */ |
| 6271 abstract class Identifier extends Expression { | 5392 abstract class IdentifierImpl extends ExpressionImpl implements Identifier { |
| 6272 /** | 5393 /** |
| 6273 * Return the best element available for this operator. If resolution was able | 5394 * Return the best element available for this operator. If resolution was able |
| 6274 * to find a better element based on type propagation, that element will be | 5395 * to find a better element based on type propagation, that element will be |
| 6275 * returned. Otherwise, the element found using the result of static analysis | 5396 * returned. Otherwise, the element found using the result of static analysis |
| 6276 * will be returned. If resolution has not been performed, then `null` will be | 5397 * will be returned. If resolution has not been performed, then `null` will be |
| 6277 * returned. | 5398 * returned. |
| 6278 */ | 5399 */ |
| 6279 Element get bestElement; | 5400 Element get bestElement; |
| 6280 | 5401 |
| 6281 @override | 5402 @override |
| 6282 bool get isAssignable => true; | 5403 bool get isAssignable => true; |
| 6283 | |
| 6284 /** | |
| 6285 * Return the lexical representation of the identifier. | |
| 6286 */ | |
| 6287 String get name; | |
| 6288 | |
| 6289 /** | |
| 6290 * Return the element associated with this identifier based on propagated type | |
| 6291 * information, or `null` if the AST structure has not been resolved or if | |
| 6292 * this identifier could not be resolved. One example of the latter case is an | |
| 6293 * identifier that is not defined within the scope in which it appears. | |
| 6294 */ | |
| 6295 Element get propagatedElement; | |
| 6296 | |
| 6297 /** | |
| 6298 * Return the element associated with this identifier based on static type | |
| 6299 * information, or `null` if the AST structure has not been resolved or if | |
| 6300 * this identifier could not be resolved. One example of the latter case is an | |
| 6301 * identifier that is not defined within the scope in which it appears | |
| 6302 */ | |
| 6303 Element get staticElement; | |
| 6304 | |
| 6305 /** | |
| 6306 * Return `true` if the given [name] is visible only within the library in | |
| 6307 * which it is declared. | |
| 6308 */ | |
| 6309 static bool isPrivateName(String name) => | |
| 6310 StringUtilities.startsWithChar(name, 0x5F); | |
| 6311 } | 5404 } |
| 6312 | 5405 |
| 6313 /** | 5406 /** |
| 6314 * An if statement. | 5407 * An if statement. |
| 6315 * | 5408 * |
| 6316 * > ifStatement ::= | 5409 * > ifStatement ::= |
| 6317 * > 'if' '(' [Expression] ')' [Statement] ('else' [Statement])? | 5410 * > 'if' '(' [Expression] ')' [Statement] ('else' [Statement])? |
| 6318 */ | 5411 */ |
| 6319 class IfStatement extends Statement { | 5412 class IfStatementImpl extends StatementImpl implements IfStatement { |
| 6320 /** | 5413 /** |
| 6321 * The token representing the 'if' keyword. | 5414 * The token representing the 'if' keyword. |
| 6322 */ | 5415 */ |
| 6323 Token ifKeyword; | 5416 Token ifKeyword; |
| 6324 | 5417 |
| 6325 /** | 5418 /** |
| 6326 * The left parenthesis. | 5419 * The left parenthesis. |
| 6327 */ | 5420 */ |
| 6328 Token leftParenthesis; | 5421 Token leftParenthesis; |
| 6329 | 5422 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6351 /** | 5444 /** |
| 6352 * The statement that is executed if the condition evaluates to `false`, or | 5445 * The statement that is executed if the condition evaluates to `false`, or |
| 6353 * `null` if there is no else statement. | 5446 * `null` if there is no else statement. |
| 6354 */ | 5447 */ |
| 6355 Statement _elseStatement; | 5448 Statement _elseStatement; |
| 6356 | 5449 |
| 6357 /** | 5450 /** |
| 6358 * Initialize a newly created if statement. The [elseKeyword] and | 5451 * Initialize a newly created if statement. The [elseKeyword] and |
| 6359 * [elseStatement] can be `null` if there is no else clause. | 5452 * [elseStatement] can be `null` if there is no else clause. |
| 6360 */ | 5453 */ |
| 6361 IfStatement( | 5454 IfStatementImpl( |
| 6362 this.ifKeyword, | 5455 this.ifKeyword, |
| 6363 this.leftParenthesis, | 5456 this.leftParenthesis, |
| 6364 Expression condition, | 5457 Expression condition, |
| 6365 this.rightParenthesis, | 5458 this.rightParenthesis, |
| 6366 Statement thenStatement, | 5459 Statement thenStatement, |
| 6367 this.elseKeyword, | 5460 this.elseKeyword, |
| 6368 Statement elseStatement) { | 5461 Statement elseStatement) { |
| 6369 _condition = _becomeParentOf(condition); | 5462 _condition = _becomeParentOf(condition); |
| 6370 _thenStatement = _becomeParentOf(thenStatement); | 5463 _thenStatement = _becomeParentOf(thenStatement); |
| 6371 _elseStatement = _becomeParentOf(elseStatement); | 5464 _elseStatement = _becomeParentOf(elseStatement); |
| 6372 } | 5465 } |
| 6373 | 5466 |
| 6374 @override | 5467 @override |
| 6375 Token get beginToken => ifKeyword; | 5468 Token get beginToken => ifKeyword; |
| 6376 | 5469 |
| 6377 @override | 5470 @override |
| 6378 Iterable get childEntities => new ChildEntities() | 5471 Iterable get childEntities => new ChildEntities() |
| 6379 ..add(ifKeyword) | 5472 ..add(ifKeyword) |
| 6380 ..add(leftParenthesis) | 5473 ..add(leftParenthesis) |
| 6381 ..add(_condition) | 5474 ..add(_condition) |
| 6382 ..add(rightParenthesis) | 5475 ..add(rightParenthesis) |
| 6383 ..add(_thenStatement) | 5476 ..add(_thenStatement) |
| 6384 ..add(elseKeyword) | 5477 ..add(elseKeyword) |
| 6385 ..add(_elseStatement); | 5478 ..add(_elseStatement); |
| 6386 | 5479 |
| 6387 /** | 5480 @override |
| 6388 * Return the condition used to determine which of the statements is executed | |
| 6389 * next. | |
| 6390 */ | |
| 6391 Expression get condition => _condition; | 5481 Expression get condition => _condition; |
| 6392 | 5482 |
| 6393 /** | 5483 @override |
| 6394 * Set the condition used to determine which of the statements is executed | |
| 6395 * next to the given [expression]. | |
| 6396 */ | |
| 6397 void set condition(Expression expression) { | 5484 void set condition(Expression expression) { |
| 6398 _condition = _becomeParentOf(expression); | 5485 _condition = _becomeParentOf(expression); |
| 6399 } | 5486 } |
| 6400 | 5487 |
| 6401 /** | 5488 @override |
| 6402 * Return the statement that is executed if the condition evaluates to | |
| 6403 * `false`, or `null` if there is no else statement. | |
| 6404 */ | |
| 6405 Statement get elseStatement => _elseStatement; | 5489 Statement get elseStatement => _elseStatement; |
| 6406 | 5490 |
| 6407 /** | 5491 @override |
| 6408 * Set the statement that is executed if the condition evaluates to `false` | |
| 6409 * to the given [statement]. | |
| 6410 */ | |
| 6411 void set elseStatement(Statement statement) { | 5492 void set elseStatement(Statement statement) { |
| 6412 _elseStatement = _becomeParentOf(statement); | 5493 _elseStatement = _becomeParentOf(statement); |
| 6413 } | 5494 } |
| 6414 | 5495 |
| 6415 @override | 5496 @override |
| 6416 Token get endToken { | 5497 Token get endToken { |
| 6417 if (_elseStatement != null) { | 5498 if (_elseStatement != null) { |
| 6418 return _elseStatement.endToken; | 5499 return _elseStatement.endToken; |
| 6419 } | 5500 } |
| 6420 return _thenStatement.endToken; | 5501 return _thenStatement.endToken; |
| 6421 } | 5502 } |
| 6422 | 5503 |
| 6423 /** | 5504 @override |
| 6424 * Return the statement that is executed if the condition evaluates to `true`. | |
| 6425 */ | |
| 6426 Statement get thenStatement => _thenStatement; | 5505 Statement get thenStatement => _thenStatement; |
| 6427 | 5506 |
| 6428 /** | 5507 @override |
| 6429 * Set the statement that is executed if the condition evaluates to `true` to | |
| 6430 * the given [statement]. | |
| 6431 */ | |
| 6432 void set thenStatement(Statement statement) { | 5508 void set thenStatement(Statement statement) { |
| 6433 _thenStatement = _becomeParentOf(statement); | 5509 _thenStatement = _becomeParentOf(statement); |
| 6434 } | 5510 } |
| 6435 | 5511 |
| 6436 @override | 5512 @override |
| 6437 accept(AstVisitor visitor) => visitor.visitIfStatement(this); | 5513 accept(AstVisitor visitor) => visitor.visitIfStatement(this); |
| 6438 | 5514 |
| 6439 @override | 5515 @override |
| 6440 void visitChildren(AstVisitor visitor) { | 5516 void visitChildren(AstVisitor visitor) { |
| 6441 _safelyVisitChild(_condition, visitor); | 5517 _safelyVisitChild(_condition, visitor); |
| 6442 _safelyVisitChild(_thenStatement, visitor); | 5518 _safelyVisitChild(_thenStatement, visitor); |
| 6443 _safelyVisitChild(_elseStatement, visitor); | 5519 _safelyVisitChild(_elseStatement, visitor); |
| 6444 } | 5520 } |
| 6445 } | 5521 } |
| 6446 | 5522 |
| 6447 /** | 5523 /** |
| 6448 * The "implements" clause in an class declaration. | 5524 * The "implements" clause in an class declaration. |
| 6449 * | 5525 * |
| 6450 * > implementsClause ::= | 5526 * > implementsClause ::= |
| 6451 * > 'implements' [TypeName] (',' [TypeName])* | 5527 * > 'implements' [TypeName] (',' [TypeName])* |
| 6452 */ | 5528 */ |
| 6453 class ImplementsClause extends AstNode { | 5529 class ImplementsClauseImpl extends AstNodeImpl implements ImplementsClause { |
| 6454 /** | 5530 /** |
| 6455 * The token representing the 'implements' keyword. | 5531 * The token representing the 'implements' keyword. |
| 6456 */ | 5532 */ |
| 6457 Token implementsKeyword; | 5533 Token implementsKeyword; |
| 6458 | 5534 |
| 6459 /** | 5535 /** |
| 6460 * The interfaces that are being implemented. | 5536 * The interfaces that are being implemented. |
| 6461 */ | 5537 */ |
| 6462 NodeList<TypeName> _interfaces; | 5538 NodeList<TypeName> _interfaces; |
| 6463 | 5539 |
| 6464 /** | 5540 /** |
| 6465 * Initialize a newly created implements clause. | 5541 * Initialize a newly created implements clause. |
| 6466 */ | 5542 */ |
| 6467 ImplementsClause(this.implementsKeyword, List<TypeName> interfaces) { | 5543 ImplementsClauseImpl(this.implementsKeyword, List<TypeName> interfaces) { |
| 6468 _interfaces = new NodeList<TypeName>(this, interfaces); | 5544 _interfaces = new NodeList<TypeName>(this, interfaces); |
| 6469 } | 5545 } |
| 6470 | 5546 |
| 6471 @override | 5547 @override |
| 6472 Token get beginToken => implementsKeyword; | 5548 Token get beginToken => implementsKeyword; |
| 6473 | 5549 |
| 6474 @override | 5550 @override |
| 6475 // TODO(paulberry): add commas. | 5551 // TODO(paulberry): add commas. |
| 6476 Iterable get childEntities => new ChildEntities() | 5552 Iterable get childEntities => new ChildEntities() |
| 6477 ..add(implementsKeyword) | 5553 ..add(implementsKeyword) |
| 6478 ..addAll(interfaces); | 5554 ..addAll(interfaces); |
| 6479 | 5555 |
| 6480 @override | 5556 @override |
| 6481 Token get endToken => _interfaces.endToken; | 5557 Token get endToken => _interfaces.endToken; |
| 6482 | 5558 |
| 6483 /** | 5559 @override |
| 6484 * Return the list of the interfaces that are being implemented. | |
| 6485 */ | |
| 6486 NodeList<TypeName> get interfaces => _interfaces; | 5560 NodeList<TypeName> get interfaces => _interfaces; |
| 6487 | 5561 |
| 6488 @override | 5562 @override |
| 6489 accept(AstVisitor visitor) => visitor.visitImplementsClause(this); | 5563 accept(AstVisitor visitor) => visitor.visitImplementsClause(this); |
| 6490 | 5564 |
| 6491 @override | 5565 @override |
| 6492 void visitChildren(AstVisitor visitor) { | 5566 void visitChildren(AstVisitor visitor) { |
| 6493 _interfaces.accept(visitor); | 5567 _interfaces.accept(visitor); |
| 6494 } | 5568 } |
| 6495 } | 5569 } |
| 6496 | 5570 |
| 6497 /** | 5571 /** |
| 6498 * An import directive. | 5572 * An import directive. |
| 6499 * | 5573 * |
| 6500 * > importDirective ::= | 5574 * > importDirective ::= |
| 6501 * > [Annotation] 'import' [StringLiteral] ('as' identifier)? [Combinator]*
';' | 5575 * > [Annotation] 'import' [StringLiteral] ('as' identifier)? [Combinator]*
';' |
| 6502 * > | [Annotation] 'import' [StringLiteral] 'deferred' 'as' identifier [Combi
nator]* ';' | 5576 * > | [Annotation] 'import' [StringLiteral] 'deferred' 'as' identifier [Combi
nator]* ';' |
| 6503 */ | 5577 */ |
| 6504 class ImportDirective extends NamespaceDirective { | 5578 class ImportDirectiveImpl extends NamespaceDirectiveImpl |
| 6505 static Comparator<ImportDirective> COMPARATOR = | 5579 implements ImportDirective { |
| 6506 (ImportDirective import1, ImportDirective import2) { | |
| 6507 // | |
| 6508 // uri | |
| 6509 // | |
| 6510 StringLiteral uri1 = import1.uri; | |
| 6511 StringLiteral uri2 = import2.uri; | |
| 6512 String uriStr1 = uri1.stringValue; | |
| 6513 String uriStr2 = uri2.stringValue; | |
| 6514 if (uriStr1 != null || uriStr2 != null) { | |
| 6515 if (uriStr1 == null) { | |
| 6516 return -1; | |
| 6517 } else if (uriStr2 == null) { | |
| 6518 return 1; | |
| 6519 } else { | |
| 6520 int compare = uriStr1.compareTo(uriStr2); | |
| 6521 if (compare != 0) { | |
| 6522 return compare; | |
| 6523 } | |
| 6524 } | |
| 6525 } | |
| 6526 // | |
| 6527 // as | |
| 6528 // | |
| 6529 SimpleIdentifier prefix1 = import1.prefix; | |
| 6530 SimpleIdentifier prefix2 = import2.prefix; | |
| 6531 String prefixStr1 = prefix1 != null ? prefix1.name : null; | |
| 6532 String prefixStr2 = prefix2 != null ? prefix2.name : null; | |
| 6533 if (prefixStr1 != null || prefixStr2 != null) { | |
| 6534 if (prefixStr1 == null) { | |
| 6535 return -1; | |
| 6536 } else if (prefixStr2 == null) { | |
| 6537 return 1; | |
| 6538 } else { | |
| 6539 int compare = prefixStr1.compareTo(prefixStr2); | |
| 6540 if (compare != 0) { | |
| 6541 return compare; | |
| 6542 } | |
| 6543 } | |
| 6544 } | |
| 6545 // | |
| 6546 // hides and shows | |
| 6547 // | |
| 6548 NodeList<Combinator> combinators1 = import1.combinators; | |
| 6549 List<String> allHides1 = new List<String>(); | |
| 6550 List<String> allShows1 = new List<String>(); | |
| 6551 for (Combinator combinator in combinators1) { | |
| 6552 if (combinator is HideCombinator) { | |
| 6553 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; | |
| 6554 for (SimpleIdentifier simpleIdentifier in hides) { | |
| 6555 allHides1.add(simpleIdentifier.name); | |
| 6556 } | |
| 6557 } else { | |
| 6558 NodeList<SimpleIdentifier> shows = | |
| 6559 (combinator as ShowCombinator).shownNames; | |
| 6560 for (SimpleIdentifier simpleIdentifier in shows) { | |
| 6561 allShows1.add(simpleIdentifier.name); | |
| 6562 } | |
| 6563 } | |
| 6564 } | |
| 6565 NodeList<Combinator> combinators2 = import2.combinators; | |
| 6566 List<String> allHides2 = new List<String>(); | |
| 6567 List<String> allShows2 = new List<String>(); | |
| 6568 for (Combinator combinator in combinators2) { | |
| 6569 if (combinator is HideCombinator) { | |
| 6570 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; | |
| 6571 for (SimpleIdentifier simpleIdentifier in hides) { | |
| 6572 allHides2.add(simpleIdentifier.name); | |
| 6573 } | |
| 6574 } else { | |
| 6575 NodeList<SimpleIdentifier> shows = | |
| 6576 (combinator as ShowCombinator).shownNames; | |
| 6577 for (SimpleIdentifier simpleIdentifier in shows) { | |
| 6578 allShows2.add(simpleIdentifier.name); | |
| 6579 } | |
| 6580 } | |
| 6581 } | |
| 6582 // test lengths of combinator lists first | |
| 6583 if (allHides1.length != allHides2.length) { | |
| 6584 return allHides1.length - allHides2.length; | |
| 6585 } | |
| 6586 if (allShows1.length != allShows2.length) { | |
| 6587 return allShows1.length - allShows2.length; | |
| 6588 } | |
| 6589 // next ensure that the lists are equivalent | |
| 6590 if (!javaCollectionContainsAll(allHides1, allHides2)) { | |
| 6591 return -1; | |
| 6592 } | |
| 6593 if (!javaCollectionContainsAll(allShows1, allShows2)) { | |
| 6594 return -1; | |
| 6595 } | |
| 6596 return 0; | |
| 6597 }; | |
| 6598 | |
| 6599 /** | 5580 /** |
| 6600 * The token representing the 'deferred' keyword, or `null` if the imported is | 5581 * The token representing the 'deferred' keyword, or `null` if the imported is |
| 6601 * not deferred. | 5582 * not deferred. |
| 6602 */ | 5583 */ |
| 6603 Token deferredKeyword; | 5584 Token deferredKeyword; |
| 6604 | 5585 |
| 6605 /** | 5586 /** |
| 6606 * The token representing the 'as' keyword, or `null` if the imported names ar
e | 5587 * The token representing the 'as' keyword, or `null` if the imported names ar
e |
| 6607 * not prefixed. | 5588 * not prefixed. |
| 6608 */ | 5589 */ |
| 6609 Token asKeyword; | 5590 Token asKeyword; |
| 6610 | 5591 |
| 6611 /** | 5592 /** |
| 6612 * The prefix to be used with the imported names, or `null` if the imported | 5593 * The prefix to be used with the imported names, or `null` if the imported |
| 6613 * names are not prefixed. | 5594 * names are not prefixed. |
| 6614 */ | 5595 */ |
| 6615 SimpleIdentifier _prefix; | 5596 SimpleIdentifier _prefix; |
| 6616 | 5597 |
| 6617 /** | 5598 /** |
| 6618 * Initialize a newly created import directive. Either or both of the | 5599 * Initialize a newly created import directive. Either or both of the |
| 6619 * [comment] and [metadata] can be `null` if the function does not have the | 5600 * [comment] and [metadata] can be `null` if the function does not have the |
| 6620 * corresponding attribute. The [deferredKeyword] can be `null` if the import | 5601 * corresponding attribute. The [deferredKeyword] can be `null` if the import |
| 6621 * is not deferred. The [asKeyword] and [prefix] can be `null` if the import | 5602 * is not deferred. The [asKeyword] and [prefix] can be `null` if the import |
| 6622 * does not specify a prefix. The list of [combinators] can be `null` if there | 5603 * does not specify a prefix. The list of [combinators] can be `null` if there |
| 6623 * are no combinators. | 5604 * are no combinators. |
| 6624 */ | 5605 */ |
| 6625 ImportDirective( | 5606 ImportDirectiveImpl( |
| 6626 Comment comment, | 5607 Comment comment, |
| 6627 List<Annotation> metadata, | 5608 List<Annotation> metadata, |
| 6628 Token keyword, | 5609 Token keyword, |
| 6629 StringLiteral libraryUri, | 5610 StringLiteral libraryUri, |
| 6630 List<Configuration> configurations, | 5611 List<Configuration> configurations, |
| 6631 this.deferredKeyword, | 5612 this.deferredKeyword, |
| 6632 this.asKeyword, | 5613 this.asKeyword, |
| 6633 SimpleIdentifier prefix, | 5614 SimpleIdentifier prefix, |
| 6634 List<Combinator> combinators, | 5615 List<Combinator> combinators, |
| 6635 Token semicolon) | 5616 Token semicolon) |
| 6636 : super(comment, metadata, keyword, libraryUri, configurations, | 5617 : super(comment, metadata, keyword, libraryUri, configurations, |
| 6637 combinators, semicolon) { | 5618 combinators, semicolon) { |
| 6638 _prefix = _becomeParentOf(prefix); | 5619 _prefix = _becomeParentOf(prefix); |
| 6639 } | 5620 } |
| 6640 | 5621 |
| 6641 @override | 5622 @override |
| 6642 Iterable get childEntities => super._childEntities | 5623 Iterable get childEntities => super._childEntities |
| 6643 ..add(_uri) | 5624 ..add(_uri) |
| 6644 ..add(deferredKeyword) | 5625 ..add(deferredKeyword) |
| 6645 ..add(asKeyword) | 5626 ..add(asKeyword) |
| 6646 ..add(_prefix) | 5627 ..add(_prefix) |
| 6647 ..addAll(combinators) | 5628 ..addAll(combinators) |
| 6648 ..add(semicolon); | 5629 ..add(semicolon); |
| 6649 | 5630 |
| 6650 @override | 5631 @override |
| 6651 ImportElement get element => super.element as ImportElement; | 5632 ImportElement get element => super.element as ImportElement; |
| 6652 | 5633 |
| 6653 /** | 5634 @override |
| 6654 * Return the prefix to be used with the imported names, or `null` if the | |
| 6655 * imported names are not prefixed. | |
| 6656 */ | |
| 6657 SimpleIdentifier get prefix => _prefix; | 5635 SimpleIdentifier get prefix => _prefix; |
| 6658 | 5636 |
| 6659 /** | 5637 @override |
| 6660 * Set the prefix to be used with the imported names to the given [identifier]
. | |
| 6661 */ | |
| 6662 void set prefix(SimpleIdentifier identifier) { | 5638 void set prefix(SimpleIdentifier identifier) { |
| 6663 _prefix = _becomeParentOf(identifier); | 5639 _prefix = _becomeParentOf(identifier); |
| 6664 } | 5640 } |
| 6665 | 5641 |
| 6666 @override | 5642 @override |
| 6667 LibraryElement get uriElement { | 5643 LibraryElement get uriElement { |
| 6668 ImportElement element = this.element; | 5644 ImportElement element = this.element; |
| 6669 if (element == null) { | 5645 if (element == null) { |
| 6670 return null; | 5646 return null; |
| 6671 } | 5647 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6682 combinators.accept(visitor); | 5658 combinators.accept(visitor); |
| 6683 } | 5659 } |
| 6684 } | 5660 } |
| 6685 | 5661 |
| 6686 /** | 5662 /** |
| 6687 * An index expression. | 5663 * An index expression. |
| 6688 * | 5664 * |
| 6689 * > indexExpression ::= | 5665 * > indexExpression ::= |
| 6690 * > [Expression] '[' [Expression] ']' | 5666 * > [Expression] '[' [Expression] ']' |
| 6691 */ | 5667 */ |
| 6692 class IndexExpression extends Expression { | 5668 class IndexExpressionImpl extends ExpressionImpl implements IndexExpression { |
| 6693 /** | 5669 /** |
| 6694 * The expression used to compute the object being indexed, or `null` if this | 5670 * The expression used to compute the object being indexed, or `null` if this |
| 6695 * index expression is part of a cascade expression. | 5671 * index expression is part of a cascade expression. |
| 6696 */ | 5672 */ |
| 6697 Expression _target; | 5673 Expression _target; |
| 6698 | 5674 |
| 6699 /** | 5675 /** |
| 6700 * The period ("..") before a cascaded index expression, or `null` if this | 5676 * The period ("..") before a cascaded index expression, or `null` if this |
| 6701 * index expression is not part of a cascade expression. | 5677 * index expression is not part of a cascade expression. |
| 6702 */ | 5678 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6735 * If this expression is both in a getter and setter context, the | 5711 * If this expression is both in a getter and setter context, the |
| 6736 * [AuxiliaryElements] will be set to hold onto the static and propagated | 5712 * [AuxiliaryElements] will be set to hold onto the static and propagated |
| 6737 * information. The auxiliary element will hold onto the elements from the | 5713 * information. The auxiliary element will hold onto the elements from the |
| 6738 * getter context. | 5714 * getter context. |
| 6739 */ | 5715 */ |
| 6740 AuxiliaryElements auxiliaryElements = null; | 5716 AuxiliaryElements auxiliaryElements = null; |
| 6741 | 5717 |
| 6742 /** | 5718 /** |
| 6743 * Initialize a newly created index expression. | 5719 * Initialize a newly created index expression. |
| 6744 */ | 5720 */ |
| 6745 IndexExpression.forCascade( | 5721 IndexExpressionImpl.forCascade( |
| 6746 this.period, this.leftBracket, Expression index, this.rightBracket) { | 5722 this.period, this.leftBracket, Expression index, this.rightBracket) { |
| 6747 _index = _becomeParentOf(index); | 5723 _index = _becomeParentOf(index); |
| 6748 } | 5724 } |
| 6749 | 5725 |
| 6750 /** | 5726 /** |
| 6751 * Initialize a newly created index expression. | 5727 * Initialize a newly created index expression. |
| 6752 */ | 5728 */ |
| 6753 IndexExpression.forTarget(Expression target, this.leftBracket, | 5729 IndexExpressionImpl.forTarget(Expression target, this.leftBracket, |
| 6754 Expression index, this.rightBracket) { | 5730 Expression index, this.rightBracket) { |
| 6755 _target = _becomeParentOf(target); | 5731 _target = _becomeParentOf(target); |
| 6756 _index = _becomeParentOf(index); | 5732 _index = _becomeParentOf(index); |
| 6757 } | 5733 } |
| 6758 | 5734 |
| 6759 @override | 5735 @override |
| 6760 Token get beginToken { | 5736 Token get beginToken { |
| 6761 if (_target != null) { | 5737 if (_target != null) { |
| 6762 return _target.beginToken; | 5738 return _target.beginToken; |
| 6763 } | 5739 } |
| 6764 return period; | 5740 return period; |
| 6765 } | 5741 } |
| 6766 | 5742 |
| 6767 /** | 5743 @override |
| 6768 * Return the best element available for this operator. If resolution was able | |
| 6769 * to find a better element based on type propagation, that element will be | |
| 6770 * returned. Otherwise, the element found using the result of static analysis | |
| 6771 * will be returned. If resolution has not been performed, then `null` will be | |
| 6772 * returned. | |
| 6773 */ | |
| 6774 MethodElement get bestElement { | 5744 MethodElement get bestElement { |
| 6775 MethodElement element = propagatedElement; | 5745 MethodElement element = propagatedElement; |
| 6776 if (element == null) { | 5746 if (element == null) { |
| 6777 element = staticElement; | 5747 element = staticElement; |
| 6778 } | 5748 } |
| 6779 return element; | 5749 return element; |
| 6780 } | 5750 } |
| 6781 | 5751 |
| 6782 @override | 5752 @override |
| 6783 Iterable get childEntities => new ChildEntities() | 5753 Iterable get childEntities => new ChildEntities() |
| 6784 ..add(_target) | 5754 ..add(_target) |
| 6785 ..add(period) | 5755 ..add(period) |
| 6786 ..add(leftBracket) | 5756 ..add(leftBracket) |
| 6787 ..add(_index) | 5757 ..add(_index) |
| 6788 ..add(rightBracket); | 5758 ..add(rightBracket); |
| 6789 | 5759 |
| 6790 @override | 5760 @override |
| 6791 Token get endToken => rightBracket; | 5761 Token get endToken => rightBracket; |
| 6792 | 5762 |
| 6793 /** | 5763 @override |
| 6794 * Return the expression used to compute the index. | |
| 6795 */ | |
| 6796 Expression get index => _index; | 5764 Expression get index => _index; |
| 6797 | 5765 |
| 6798 /** | 5766 @override |
| 6799 * Set the expression used to compute the index to the given [expression]. | |
| 6800 */ | |
| 6801 void set index(Expression expression) { | 5767 void set index(Expression expression) { |
| 6802 _index = _becomeParentOf(expression); | 5768 _index = _becomeParentOf(expression); |
| 6803 } | 5769 } |
| 6804 | 5770 |
| 6805 @override | 5771 @override |
| 6806 bool get isAssignable => true; | 5772 bool get isAssignable => true; |
| 6807 | 5773 |
| 6808 /** | 5774 @override |
| 6809 * Return `true` if this expression is cascaded. If it is, then the target of | |
| 6810 * this expression is not stored locally but is stored in the nearest ancestor | |
| 6811 * that is a [CascadeExpression]. | |
| 6812 */ | |
| 6813 bool get isCascaded => period != null; | 5775 bool get isCascaded => period != null; |
| 6814 | 5776 |
| 6815 @override | 5777 @override |
| 6816 int get precedence => 15; | 5778 int get precedence => 15; |
| 6817 | 5779 |
| 6818 /** | 5780 @override |
| 6819 * Return the expression used to compute the object being indexed. If this | |
| 6820 * index expression is not part of a cascade expression, then this is the same | |
| 6821 * as [target]. If this index expression is part of a cascade expression, then | |
| 6822 * the target expression stored with the cascade expression is returned. | |
| 6823 */ | |
| 6824 Expression get realTarget { | 5781 Expression get realTarget { |
| 6825 if (isCascaded) { | 5782 if (isCascaded) { |
| 6826 AstNode ancestor = parent; | 5783 AstNode ancestor = parent; |
| 6827 while (ancestor is! CascadeExpression) { | 5784 while (ancestor is! CascadeExpression) { |
| 6828 if (ancestor == null) { | 5785 if (ancestor == null) { |
| 6829 return _target; | 5786 return _target; |
| 6830 } | 5787 } |
| 6831 ancestor = ancestor.parent; | 5788 ancestor = ancestor.parent; |
| 6832 } | 5789 } |
| 6833 return (ancestor as CascadeExpression).target; | 5790 return (ancestor as CascadeExpression).target; |
| 6834 } | 5791 } |
| 6835 return _target; | 5792 return _target; |
| 6836 } | 5793 } |
| 6837 | 5794 |
| 6838 /** | 5795 @override |
| 6839 * Return the expression used to compute the object being indexed, or `null` | |
| 6840 * if this index expression is part of a cascade expression. | |
| 6841 * | |
| 6842 * Use [realTarget] to get the target independent of whether this is part of a | |
| 6843 * cascade expression. | |
| 6844 */ | |
| 6845 Expression get target => _target; | 5796 Expression get target => _target; |
| 6846 | 5797 |
| 6847 /** | 5798 @override |
| 6848 * Set the expression used to compute the object being indexed to the given | |
| 6849 * [expression]. | |
| 6850 */ | |
| 6851 void set target(Expression expression) { | 5799 void set target(Expression expression) { |
| 6852 _target = _becomeParentOf(expression); | 5800 _target = _becomeParentOf(expression); |
| 6853 } | 5801 } |
| 6854 | 5802 |
| 6855 /** | 5803 /** |
| 6856 * If the AST structure has been resolved, and the function being invoked is | 5804 * If the AST structure has been resolved, and the function being invoked is |
| 6857 * known based on propagated type information, then return the parameter | 5805 * known based on propagated type information, then return the parameter |
| 6858 * element representing the parameter to which the value of the index | 5806 * element representing the parameter to which the value of the index |
| 6859 * expression will be bound. Otherwise, return `null`. | 5807 * expression will be bound. Otherwise, return `null`. |
| 6860 */ | 5808 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6882 List<ParameterElement> parameters = staticElement.parameters; | 5830 List<ParameterElement> parameters = staticElement.parameters; |
| 6883 if (parameters.length < 1) { | 5831 if (parameters.length < 1) { |
| 6884 return null; | 5832 return null; |
| 6885 } | 5833 } |
| 6886 return parameters[0]; | 5834 return parameters[0]; |
| 6887 } | 5835 } |
| 6888 | 5836 |
| 6889 @override | 5837 @override |
| 6890 accept(AstVisitor visitor) => visitor.visitIndexExpression(this); | 5838 accept(AstVisitor visitor) => visitor.visitIndexExpression(this); |
| 6891 | 5839 |
| 6892 /** | 5840 @override |
| 6893 * Return `true` if this expression is computing a right-hand value (that is, | |
| 6894 * if this expression is in a context where the operator '[]' will be | |
| 6895 * invoked). | |
| 6896 * | |
| 6897 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor | |
| 6898 * are they mutually exclusive. In other words, it is possible for both | |
| 6899 * methods to return `true` when invoked on the same node. | |
| 6900 */ | |
| 6901 bool inGetterContext() { | 5841 bool inGetterContext() { |
| 6902 // TODO(brianwilkerson) Convert this to a getter. | 5842 // TODO(brianwilkerson) Convert this to a getter. |
| 6903 AstNode parent = this.parent; | 5843 AstNode parent = this.parent; |
| 6904 if (parent is AssignmentExpression) { | 5844 if (parent is AssignmentExpression) { |
| 6905 AssignmentExpression assignment = parent; | 5845 AssignmentExpression assignment = parent; |
| 6906 if (identical(assignment.leftHandSide, this) && | 5846 if (identical(assignment.leftHandSide, this) && |
| 6907 assignment.operator.type == TokenType.EQ) { | 5847 assignment.operator.type == TokenType.EQ) { |
| 6908 return false; | 5848 return false; |
| 6909 } | 5849 } |
| 6910 } | 5850 } |
| 6911 return true; | 5851 return true; |
| 6912 } | 5852 } |
| 6913 | 5853 |
| 6914 /** | 5854 @override |
| 6915 * Return `true` if this expression is computing a left-hand value (that is, | |
| 6916 * if this expression is in a context where the operator '[]=' will be | |
| 6917 * invoked). | |
| 6918 * | |
| 6919 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor | |
| 6920 * are they mutually exclusive. In other words, it is possible for both | |
| 6921 * methods to return `true` when invoked on the same node. | |
| 6922 */ | |
| 6923 bool inSetterContext() { | 5855 bool inSetterContext() { |
| 6924 // TODO(brianwilkerson) Convert this to a getter. | 5856 // TODO(brianwilkerson) Convert this to a getter. |
| 6925 AstNode parent = this.parent; | 5857 AstNode parent = this.parent; |
| 6926 if (parent is PrefixExpression) { | 5858 if (parent is PrefixExpression) { |
| 6927 return parent.operator.type.isIncrementOperator; | 5859 return parent.operator.type.isIncrementOperator; |
| 6928 } else if (parent is PostfixExpression) { | 5860 } else if (parent is PostfixExpression) { |
| 6929 return true; | 5861 return true; |
| 6930 } else if (parent is AssignmentExpression) { | 5862 } else if (parent is AssignmentExpression) { |
| 6931 return identical(parent.leftHandSide, this); | 5863 return identical(parent.leftHandSide, this); |
| 6932 } | 5864 } |
| 6933 return false; | 5865 return false; |
| 6934 } | 5866 } |
| 6935 | 5867 |
| 6936 @override | 5868 @override |
| 6937 void visitChildren(AstVisitor visitor) { | 5869 void visitChildren(AstVisitor visitor) { |
| 6938 _safelyVisitChild(_target, visitor); | 5870 _safelyVisitChild(_target, visitor); |
| 6939 _safelyVisitChild(_index, visitor); | 5871 _safelyVisitChild(_index, visitor); |
| 6940 } | 5872 } |
| 6941 } | 5873 } |
| 6942 | 5874 |
| 6943 /** | 5875 /** |
| 6944 * An instance creation expression. | 5876 * An instance creation expression. |
| 6945 * | 5877 * |
| 6946 * > newExpression ::= | 5878 * > newExpression ::= |
| 6947 * > ('new' | 'const') [TypeName] ('.' [SimpleIdentifier])? [ArgumentList] | 5879 * > ('new' | 'const') [TypeName] ('.' [SimpleIdentifier])? [ArgumentList] |
| 6948 */ | 5880 */ |
| 6949 class InstanceCreationExpression extends Expression { | 5881 class InstanceCreationExpressionImpl extends ExpressionImpl |
| 5882 implements InstanceCreationExpression { |
| 6950 /** | 5883 /** |
| 6951 * The 'new' or 'const' keyword used to indicate how an object should be | 5884 * The 'new' or 'const' keyword used to indicate how an object should be |
| 6952 * created. | 5885 * created. |
| 6953 */ | 5886 */ |
| 6954 Token keyword; | 5887 Token keyword; |
| 6955 | 5888 |
| 6956 /** | 5889 /** |
| 6957 * The name of the constructor to be invoked. | 5890 * The name of the constructor to be invoked. |
| 6958 */ | 5891 */ |
| 6959 ConstructorName _constructorName; | 5892 ConstructorName _constructorName; |
| 6960 | 5893 |
| 6961 /** | 5894 /** |
| 6962 * The list of arguments to the constructor. | 5895 * The list of arguments to the constructor. |
| 6963 */ | 5896 */ |
| 6964 ArgumentList _argumentList; | 5897 ArgumentList _argumentList; |
| 6965 | 5898 |
| 6966 /** | 5899 /** |
| 6967 * The element associated with the constructor based on static type | 5900 * The element associated with the constructor based on static type |
| 6968 * information, or `null` if the AST structure has not been resolved or if the | 5901 * information, or `null` if the AST structure has not been resolved or if the |
| 6969 * constructor could not be resolved. | 5902 * constructor could not be resolved. |
| 6970 */ | 5903 */ |
| 6971 ConstructorElement staticElement; | 5904 ConstructorElement staticElement; |
| 6972 | 5905 |
| 6973 /** | 5906 /** |
| 6974 * Initialize a newly created instance creation expression. | 5907 * Initialize a newly created instance creation expression. |
| 6975 */ | 5908 */ |
| 6976 InstanceCreationExpression(this.keyword, ConstructorName constructorName, | 5909 InstanceCreationExpressionImpl(this.keyword, ConstructorName constructorName, |
| 6977 ArgumentList argumentList) { | 5910 ArgumentList argumentList) { |
| 6978 _constructorName = _becomeParentOf(constructorName); | 5911 _constructorName = _becomeParentOf(constructorName); |
| 6979 _argumentList = _becomeParentOf(argumentList); | 5912 _argumentList = _becomeParentOf(argumentList); |
| 6980 } | 5913 } |
| 6981 | 5914 |
| 6982 /** | 5915 @override |
| 6983 * Return the list of arguments to the constructor. | |
| 6984 */ | |
| 6985 ArgumentList get argumentList => _argumentList; | 5916 ArgumentList get argumentList => _argumentList; |
| 6986 | 5917 |
| 6987 /** | 5918 @override |
| 6988 * Set the list of arguments to the constructor to the given [argumentList]. | |
| 6989 */ | |
| 6990 void set argumentList(ArgumentList argumentList) { | 5919 void set argumentList(ArgumentList argumentList) { |
| 6991 _argumentList = _becomeParentOf(argumentList); | 5920 _argumentList = _becomeParentOf(argumentList); |
| 6992 } | 5921 } |
| 6993 | 5922 |
| 6994 @override | 5923 @override |
| 6995 Token get beginToken => keyword; | 5924 Token get beginToken => keyword; |
| 6996 | 5925 |
| 6997 @override | 5926 @override |
| 6998 Iterable get childEntities => new ChildEntities() | 5927 Iterable get childEntities => new ChildEntities() |
| 6999 ..add(keyword) | 5928 ..add(keyword) |
| 7000 ..add(_constructorName) | 5929 ..add(_constructorName) |
| 7001 ..add(_argumentList); | 5930 ..add(_argumentList); |
| 7002 | 5931 |
| 7003 /** | 5932 @override |
| 7004 * Return the name of the constructor to be invoked. | |
| 7005 */ | |
| 7006 ConstructorName get constructorName => _constructorName; | 5933 ConstructorName get constructorName => _constructorName; |
| 7007 | 5934 |
| 7008 /** | 5935 @override |
| 7009 * Set the name of the constructor to be invoked to the given [name]. | |
| 7010 */ | |
| 7011 void set constructorName(ConstructorName name) { | 5936 void set constructorName(ConstructorName name) { |
| 7012 _constructorName = _becomeParentOf(name); | 5937 _constructorName = _becomeParentOf(name); |
| 7013 } | 5938 } |
| 7014 | 5939 |
| 7015 @override | 5940 @override |
| 7016 Token get endToken => _argumentList.endToken; | 5941 Token get endToken => _argumentList.endToken; |
| 7017 | 5942 |
| 7018 /** | 5943 @override |
| 7019 * Return `true` if this creation expression is used to invoke a constant | |
| 7020 * constructor. | |
| 7021 */ | |
| 7022 bool get isConst => | 5944 bool get isConst => |
| 7023 keyword is KeywordToken && | 5945 keyword is KeywordToken && |
| 7024 (keyword as KeywordToken).keyword == Keyword.CONST; | 5946 (keyword as KeywordToken).keyword == Keyword.CONST; |
| 7025 | 5947 |
| 7026 @override | 5948 @override |
| 7027 int get precedence => 16; | 5949 int get precedence => 16; |
| 7028 | 5950 |
| 7029 @override | 5951 @override |
| 7030 accept(AstVisitor visitor) => visitor.visitInstanceCreationExpression(this); | 5952 accept(AstVisitor visitor) => visitor.visitInstanceCreationExpression(this); |
| 7031 | 5953 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7043 * > decimalIntegerLiteral | 5965 * > decimalIntegerLiteral |
| 7044 * > | hexadecimalIntegerLiteral | 5966 * > | hexadecimalIntegerLiteral |
| 7045 * > | 5967 * > |
| 7046 * > decimalIntegerLiteral ::= | 5968 * > decimalIntegerLiteral ::= |
| 7047 * > decimalDigit+ | 5969 * > decimalDigit+ |
| 7048 * > | 5970 * > |
| 7049 * > hexadecimalIntegerLiteral ::= | 5971 * > hexadecimalIntegerLiteral ::= |
| 7050 * > '0x' hexadecimalDigit+ | 5972 * > '0x' hexadecimalDigit+ |
| 7051 * > | '0X' hexadecimalDigit+ | 5973 * > | '0X' hexadecimalDigit+ |
| 7052 */ | 5974 */ |
| 7053 class IntegerLiteral extends Literal { | 5975 class IntegerLiteralImpl extends LiteralImpl implements IntegerLiteral { |
| 7054 /** | 5976 /** |
| 7055 * The token representing the literal. | 5977 * The token representing the literal. |
| 7056 */ | 5978 */ |
| 7057 Token literal; | 5979 Token literal; |
| 7058 | 5980 |
| 7059 /** | 5981 /** |
| 7060 * The value of the literal. | 5982 * The value of the literal. |
| 7061 */ | 5983 */ |
| 7062 int value = 0; | 5984 int value = 0; |
| 7063 | 5985 |
| 7064 /** | 5986 /** |
| 7065 * Initialize a newly created integer literal. | 5987 * Initialize a newly created integer literal. |
| 7066 */ | 5988 */ |
| 7067 IntegerLiteral(this.literal, this.value); | 5989 IntegerLiteralImpl(this.literal, this.value); |
| 7068 | 5990 |
| 7069 @override | 5991 @override |
| 7070 Token get beginToken => literal; | 5992 Token get beginToken => literal; |
| 7071 | 5993 |
| 7072 @override | 5994 @override |
| 7073 Iterable get childEntities => new ChildEntities()..add(literal); | 5995 Iterable get childEntities => new ChildEntities()..add(literal); |
| 7074 | 5996 |
| 7075 @override | 5997 @override |
| 7076 Token get endToken => literal; | 5998 Token get endToken => literal; |
| 7077 | 5999 |
| 7078 @override | 6000 @override |
| 7079 accept(AstVisitor visitor) => visitor.visitIntegerLiteral(this); | 6001 accept(AstVisitor visitor) => visitor.visitIntegerLiteral(this); |
| 7080 | 6002 |
| 7081 @override | 6003 @override |
| 7082 void visitChildren(AstVisitor visitor) { | 6004 void visitChildren(AstVisitor visitor) { |
| 7083 // There are no children to visit. | 6005 // There are no children to visit. |
| 7084 } | 6006 } |
| 7085 } | 6007 } |
| 7086 | 6008 |
| 7087 /** | 6009 /** |
| 7088 * A node within a [StringInterpolation]. | 6010 * A node within a [StringInterpolation]. |
| 7089 * | 6011 * |
| 7090 * > interpolationElement ::= | 6012 * > interpolationElement ::= |
| 7091 * > [InterpolationExpression] | 6013 * > [InterpolationExpression] |
| 7092 * > | [InterpolationString] | 6014 * > | [InterpolationString] |
| 7093 */ | 6015 */ |
| 7094 abstract class InterpolationElement extends AstNode {} | 6016 abstract class InterpolationElementImpl extends AstNodeImpl |
| 6017 implements InterpolationElement {} |
| 7095 | 6018 |
| 7096 /** | 6019 /** |
| 7097 * An expression embedded in a string interpolation. | 6020 * An expression embedded in a string interpolation. |
| 7098 * | 6021 * |
| 7099 * > interpolationExpression ::= | 6022 * > interpolationExpression ::= |
| 7100 * > '$' [SimpleIdentifier] | 6023 * > '$' [SimpleIdentifier] |
| 7101 * > | '$' '{' [Expression] '}' | 6024 * > | '$' '{' [Expression] '}' |
| 7102 */ | 6025 */ |
| 7103 class InterpolationExpression extends InterpolationElement { | 6026 class InterpolationExpressionImpl extends InterpolationElementImpl |
| 6027 implements InterpolationExpression { |
| 7104 /** | 6028 /** |
| 7105 * The token used to introduce the interpolation expression; either '$' if the | 6029 * The token used to introduce the interpolation expression; either '$' if the |
| 7106 * expression is a simple identifier or '${' if the expression is a full | 6030 * expression is a simple identifier or '${' if the expression is a full |
| 7107 * expression. | 6031 * expression. |
| 7108 */ | 6032 */ |
| 7109 Token leftBracket; | 6033 Token leftBracket; |
| 7110 | 6034 |
| 7111 /** | 6035 /** |
| 7112 * The expression to be evaluated for the value to be converted into a string. | 6036 * The expression to be evaluated for the value to be converted into a string. |
| 7113 */ | 6037 */ |
| 7114 Expression _expression; | 6038 Expression _expression; |
| 7115 | 6039 |
| 7116 /** | 6040 /** |
| 7117 * The right curly bracket, or `null` if the expression is an identifier | 6041 * The right curly bracket, or `null` if the expression is an identifier |
| 7118 * without brackets. | 6042 * without brackets. |
| 7119 */ | 6043 */ |
| 7120 Token rightBracket; | 6044 Token rightBracket; |
| 7121 | 6045 |
| 7122 /** | 6046 /** |
| 7123 * Initialize a newly created interpolation expression. | 6047 * Initialize a newly created interpolation expression. |
| 7124 */ | 6048 */ |
| 7125 InterpolationExpression( | 6049 InterpolationExpressionImpl( |
| 7126 this.leftBracket, Expression expression, this.rightBracket) { | 6050 this.leftBracket, Expression expression, this.rightBracket) { |
| 7127 _expression = _becomeParentOf(expression); | 6051 _expression = _becomeParentOf(expression); |
| 7128 } | 6052 } |
| 7129 | 6053 |
| 7130 @override | 6054 @override |
| 7131 Token get beginToken => leftBracket; | 6055 Token get beginToken => leftBracket; |
| 7132 | 6056 |
| 7133 @override | 6057 @override |
| 7134 Iterable get childEntities => new ChildEntities() | 6058 Iterable get childEntities => new ChildEntities() |
| 7135 ..add(leftBracket) | 6059 ..add(leftBracket) |
| 7136 ..add(_expression) | 6060 ..add(_expression) |
| 7137 ..add(rightBracket); | 6061 ..add(rightBracket); |
| 7138 | 6062 |
| 7139 @override | 6063 @override |
| 7140 Token get endToken { | 6064 Token get endToken { |
| 7141 if (rightBracket != null) { | 6065 if (rightBracket != null) { |
| 7142 return rightBracket; | 6066 return rightBracket; |
| 7143 } | 6067 } |
| 7144 return _expression.endToken; | 6068 return _expression.endToken; |
| 7145 } | 6069 } |
| 7146 | 6070 |
| 7147 /** | 6071 @override |
| 7148 * Return the expression to be evaluated for the value to be converted into a | |
| 7149 * string. | |
| 7150 */ | |
| 7151 Expression get expression => _expression; | 6072 Expression get expression => _expression; |
| 7152 | 6073 |
| 7153 /** | 6074 @override |
| 7154 * Set the expression to be evaluated for the value to be converted into a | |
| 7155 * string to the given [expression]. | |
| 7156 */ | |
| 7157 void set expression(Expression expression) { | 6075 void set expression(Expression expression) { |
| 7158 _expression = _becomeParentOf(expression); | 6076 _expression = _becomeParentOf(expression); |
| 7159 } | 6077 } |
| 7160 | 6078 |
| 7161 @override | 6079 @override |
| 7162 accept(AstVisitor visitor) => visitor.visitInterpolationExpression(this); | 6080 accept(AstVisitor visitor) => visitor.visitInterpolationExpression(this); |
| 7163 | 6081 |
| 7164 @override | 6082 @override |
| 7165 void visitChildren(AstVisitor visitor) { | 6083 void visitChildren(AstVisitor visitor) { |
| 7166 _safelyVisitChild(_expression, visitor); | 6084 _safelyVisitChild(_expression, visitor); |
| 7167 } | 6085 } |
| 7168 } | 6086 } |
| 7169 | 6087 |
| 7170 /** | 6088 /** |
| 7171 * A non-empty substring of an interpolated string. | 6089 * A non-empty substring of an interpolated string. |
| 7172 * | 6090 * |
| 7173 * > interpolationString ::= | 6091 * > interpolationString ::= |
| 7174 * > characters | 6092 * > characters |
| 7175 */ | 6093 */ |
| 7176 class InterpolationString extends InterpolationElement { | 6094 class InterpolationStringImpl extends InterpolationElementImpl |
| 6095 implements InterpolationString { |
| 7177 /** | 6096 /** |
| 7178 * The characters that will be added to the string. | 6097 * The characters that will be added to the string. |
| 7179 */ | 6098 */ |
| 7180 Token contents; | 6099 Token contents; |
| 7181 | 6100 |
| 7182 /** | 6101 /** |
| 7183 * The value of the literal. | 6102 * The value of the literal. |
| 7184 */ | 6103 */ |
| 7185 String value; | 6104 String value; |
| 7186 | 6105 |
| 7187 /** | 6106 /** |
| 7188 * Initialize a newly created string of characters that are part of a string | 6107 * Initialize a newly created string of characters that are part of a string |
| 7189 * interpolation. | 6108 * interpolation. |
| 7190 */ | 6109 */ |
| 7191 InterpolationString(this.contents, this.value); | 6110 InterpolationStringImpl(this.contents, this.value); |
| 7192 | 6111 |
| 7193 @override | 6112 @override |
| 7194 Token get beginToken => contents; | 6113 Token get beginToken => contents; |
| 7195 | 6114 |
| 7196 @override | 6115 @override |
| 7197 Iterable get childEntities => new ChildEntities()..add(contents); | 6116 Iterable get childEntities => new ChildEntities()..add(contents); |
| 7198 | 6117 |
| 7199 /** | 6118 @override |
| 7200 * Return the offset of the after-last contents character. | |
| 7201 */ | |
| 7202 int get contentsEnd { | 6119 int get contentsEnd { |
| 7203 String lexeme = contents.lexeme; | 6120 String lexeme = contents.lexeme; |
| 7204 return offset + new StringLexemeHelper(lexeme, true, true).end; | 6121 return offset + new StringLexemeHelper(lexeme, true, true).end; |
| 7205 } | 6122 } |
| 7206 | 6123 |
| 7207 /** | 6124 @override |
| 7208 * Return the offset of the first contents character. | |
| 7209 */ | |
| 7210 int get contentsOffset { | 6125 int get contentsOffset { |
| 7211 int offset = contents.offset; | 6126 int offset = contents.offset; |
| 7212 String lexeme = contents.lexeme; | 6127 String lexeme = contents.lexeme; |
| 7213 return offset + new StringLexemeHelper(lexeme, true, true).start; | 6128 return offset + new StringLexemeHelper(lexeme, true, true).start; |
| 7214 } | 6129 } |
| 7215 | 6130 |
| 7216 @override | 6131 @override |
| 7217 Token get endToken => contents; | 6132 Token get endToken => contents; |
| 7218 | 6133 |
| 7219 @override | 6134 @override |
| 7220 accept(AstVisitor visitor) => visitor.visitInterpolationString(this); | 6135 accept(AstVisitor visitor) => visitor.visitInterpolationString(this); |
| 7221 | 6136 |
| 7222 @override | 6137 @override |
| 7223 void visitChildren(AstVisitor visitor) {} | 6138 void visitChildren(AstVisitor visitor) {} |
| 7224 } | 6139 } |
| 7225 | 6140 |
| 7226 /** | 6141 /** |
| 7227 * An is expression. | 6142 * An is expression. |
| 7228 * | 6143 * |
| 7229 * > isExpression ::= | 6144 * > isExpression ::= |
| 7230 * > [Expression] 'is' '!'? [TypeName] | 6145 * > [Expression] 'is' '!'? [TypeName] |
| 7231 */ | 6146 */ |
| 7232 class IsExpression extends Expression { | 6147 class IsExpressionImpl extends ExpressionImpl implements IsExpression { |
| 7233 /** | 6148 /** |
| 7234 * The expression used to compute the value whose type is being tested. | 6149 * The expression used to compute the value whose type is being tested. |
| 7235 */ | 6150 */ |
| 7236 Expression _expression; | 6151 Expression _expression; |
| 7237 | 6152 |
| 7238 /** | 6153 /** |
| 7239 * The is operator. | 6154 * The is operator. |
| 7240 */ | 6155 */ |
| 7241 Token isOperator; | 6156 Token isOperator; |
| 7242 | 6157 |
| 7243 /** | 6158 /** |
| 7244 * The not operator, or `null` if the sense of the test is not negated. | 6159 * The not operator, or `null` if the sense of the test is not negated. |
| 7245 */ | 6160 */ |
| 7246 Token notOperator; | 6161 Token notOperator; |
| 7247 | 6162 |
| 7248 /** | 6163 /** |
| 7249 * The name of the type being tested for. | 6164 * The name of the type being tested for. |
| 7250 */ | 6165 */ |
| 7251 TypeName _type; | 6166 TypeName _type; |
| 7252 | 6167 |
| 7253 /** | 6168 /** |
| 7254 * Initialize a newly created is expression. The [notOperator] can be `null` | 6169 * Initialize a newly created is expression. The [notOperator] can be `null` |
| 7255 * if the sense of the test is not negated. | 6170 * if the sense of the test is not negated. |
| 7256 */ | 6171 */ |
| 7257 IsExpression( | 6172 IsExpressionImpl( |
| 7258 Expression expression, this.isOperator, this.notOperator, TypeName type) { | 6173 Expression expression, this.isOperator, this.notOperator, TypeName type) { |
| 7259 _expression = _becomeParentOf(expression); | 6174 _expression = _becomeParentOf(expression); |
| 7260 _type = _becomeParentOf(type); | 6175 _type = _becomeParentOf(type); |
| 7261 } | 6176 } |
| 7262 | 6177 |
| 7263 @override | 6178 @override |
| 7264 Token get beginToken => _expression.beginToken; | 6179 Token get beginToken => _expression.beginToken; |
| 7265 | 6180 |
| 7266 @override | 6181 @override |
| 7267 Iterable get childEntities => new ChildEntities() | 6182 Iterable get childEntities => new ChildEntities() |
| 7268 ..add(_expression) | 6183 ..add(_expression) |
| 7269 ..add(isOperator) | 6184 ..add(isOperator) |
| 7270 ..add(notOperator) | 6185 ..add(notOperator) |
| 7271 ..add(_type); | 6186 ..add(_type); |
| 7272 | 6187 |
| 7273 @override | 6188 @override |
| 7274 Token get endToken => _type.endToken; | 6189 Token get endToken => _type.endToken; |
| 7275 | 6190 |
| 7276 /** | 6191 @override |
| 7277 * Return the expression used to compute the value whose type is being tested. | |
| 7278 */ | |
| 7279 Expression get expression => _expression; | 6192 Expression get expression => _expression; |
| 7280 | 6193 |
| 7281 /** | 6194 @override |
| 7282 * Set the expression used to compute the value whose type is being tested to | |
| 7283 * the given [expression]. | |
| 7284 */ | |
| 7285 void set expression(Expression expression) { | 6195 void set expression(Expression expression) { |
| 7286 _expression = _becomeParentOf(expression); | 6196 _expression = _becomeParentOf(expression); |
| 7287 } | 6197 } |
| 7288 | 6198 |
| 7289 @override | 6199 @override |
| 7290 int get precedence => 7; | 6200 int get precedence => 7; |
| 7291 | 6201 |
| 7292 /** | 6202 @override |
| 7293 * Return the name of the type being tested for. | |
| 7294 */ | |
| 7295 TypeName get type => _type; | 6203 TypeName get type => _type; |
| 7296 | 6204 |
| 7297 /** | 6205 @override |
| 7298 * Set the name of the type being tested for to the given [name]. | |
| 7299 */ | |
| 7300 void set type(TypeName name) { | 6206 void set type(TypeName name) { |
| 7301 _type = _becomeParentOf(name); | 6207 _type = _becomeParentOf(name); |
| 7302 } | 6208 } |
| 7303 | 6209 |
| 7304 @override | 6210 @override |
| 7305 accept(AstVisitor visitor) => visitor.visitIsExpression(this); | 6211 accept(AstVisitor visitor) => visitor.visitIsExpression(this); |
| 7306 | 6212 |
| 7307 @override | 6213 @override |
| 7308 void visitChildren(AstVisitor visitor) { | 6214 void visitChildren(AstVisitor visitor) { |
| 7309 _safelyVisitChild(_expression, visitor); | 6215 _safelyVisitChild(_expression, visitor); |
| 7310 _safelyVisitChild(_type, visitor); | 6216 _safelyVisitChild(_type, visitor); |
| 7311 } | 6217 } |
| 7312 } | 6218 } |
| 7313 | 6219 |
| 7314 /** | 6220 /** |
| 7315 * A label on either a [LabeledStatement] or a [NamedExpression]. | |
| 7316 * | |
| 7317 * > label ::= | |
| 7318 * > [SimpleIdentifier] ':' | |
| 7319 */ | |
| 7320 class Label extends AstNode { | |
| 7321 /** | |
| 7322 * The label being associated with the statement. | |
| 7323 */ | |
| 7324 SimpleIdentifier _label; | |
| 7325 | |
| 7326 /** | |
| 7327 * The colon that separates the label from the statement. | |
| 7328 */ | |
| 7329 Token colon; | |
| 7330 | |
| 7331 /** | |
| 7332 * Initialize a newly created label. | |
| 7333 */ | |
| 7334 Label(SimpleIdentifier label, this.colon) { | |
| 7335 _label = _becomeParentOf(label); | |
| 7336 } | |
| 7337 | |
| 7338 @override | |
| 7339 Token get beginToken => _label.beginToken; | |
| 7340 | |
| 7341 @override | |
| 7342 Iterable get childEntities => new ChildEntities()..add(_label)..add(colon); | |
| 7343 | |
| 7344 @override | |
| 7345 Token get endToken => colon; | |
| 7346 | |
| 7347 /** | |
| 7348 * Return the label being associated with the statement. | |
| 7349 */ | |
| 7350 SimpleIdentifier get label => _label; | |
| 7351 | |
| 7352 /** | |
| 7353 * Set the label being associated with the statement to the given [label]. | |
| 7354 */ | |
| 7355 void set label(SimpleIdentifier label) { | |
| 7356 _label = _becomeParentOf(label); | |
| 7357 } | |
| 7358 | |
| 7359 @override | |
| 7360 accept(AstVisitor visitor) => visitor.visitLabel(this); | |
| 7361 | |
| 7362 @override | |
| 7363 void visitChildren(AstVisitor visitor) { | |
| 7364 _safelyVisitChild(_label, visitor); | |
| 7365 } | |
| 7366 } | |
| 7367 | |
| 7368 /** | |
| 7369 * A statement that has a label associated with them. | 6221 * A statement that has a label associated with them. |
| 7370 * | 6222 * |
| 7371 * > labeledStatement ::= | 6223 * > labeledStatement ::= |
| 7372 * > [Label]+ [Statement] | 6224 * > [Label]+ [Statement] |
| 7373 */ | 6225 */ |
| 7374 class LabeledStatement extends Statement { | 6226 class LabeledStatementImpl extends StatementImpl implements LabeledStatement { |
| 7375 /** | 6227 /** |
| 7376 * The labels being associated with the statement. | 6228 * The labels being associated with the statement. |
| 7377 */ | 6229 */ |
| 7378 NodeList<Label> _labels; | 6230 NodeList<Label> _labels; |
| 7379 | 6231 |
| 7380 /** | 6232 /** |
| 7381 * The statement with which the labels are being associated. | 6233 * The statement with which the labels are being associated. |
| 7382 */ | 6234 */ |
| 7383 Statement _statement; | 6235 Statement _statement; |
| 7384 | 6236 |
| 7385 /** | 6237 /** |
| 7386 * Initialize a newly created labeled statement. | 6238 * Initialize a newly created labeled statement. |
| 7387 */ | 6239 */ |
| 7388 LabeledStatement(List<Label> labels, Statement statement) { | 6240 LabeledStatementImpl(List<Label> labels, Statement statement) { |
| 7389 _labels = new NodeList<Label>(this, labels); | 6241 _labels = new NodeList<Label>(this, labels); |
| 7390 _statement = _becomeParentOf(statement); | 6242 _statement = _becomeParentOf(statement); |
| 7391 } | 6243 } |
| 7392 | 6244 |
| 7393 @override | 6245 @override |
| 7394 Token get beginToken { | 6246 Token get beginToken { |
| 7395 if (!_labels.isEmpty) { | 6247 if (!_labels.isEmpty) { |
| 7396 return _labels.beginToken; | 6248 return _labels.beginToken; |
| 7397 } | 6249 } |
| 7398 return _statement.beginToken; | 6250 return _statement.beginToken; |
| 7399 } | 6251 } |
| 7400 | 6252 |
| 7401 @override | 6253 @override |
| 7402 Iterable get childEntities => new ChildEntities() | 6254 Iterable get childEntities => new ChildEntities() |
| 7403 ..addAll(_labels) | 6255 ..addAll(_labels) |
| 7404 ..add(_statement); | 6256 ..add(_statement); |
| 7405 | 6257 |
| 7406 @override | 6258 @override |
| 7407 Token get endToken => _statement.endToken; | 6259 Token get endToken => _statement.endToken; |
| 7408 | 6260 |
| 7409 /** | 6261 @override |
| 7410 * Return the labels being associated with the statement. | |
| 7411 */ | |
| 7412 NodeList<Label> get labels => _labels; | 6262 NodeList<Label> get labels => _labels; |
| 7413 | 6263 |
| 7414 /** | 6264 @override |
| 7415 * Return the statement with which the labels are being associated. | |
| 7416 */ | |
| 7417 Statement get statement => _statement; | 6265 Statement get statement => _statement; |
| 7418 | 6266 |
| 7419 /** | 6267 @override |
| 7420 * Set the statement with which the labels are being associated to the given | |
| 7421 * [statement]. | |
| 7422 */ | |
| 7423 void set statement(Statement statement) { | 6268 void set statement(Statement statement) { |
| 7424 _statement = _becomeParentOf(statement); | 6269 _statement = _becomeParentOf(statement); |
| 7425 } | 6270 } |
| 7426 | 6271 |
| 7427 @override | 6272 @override |
| 7428 Statement get unlabeled => _statement.unlabeled; | 6273 Statement get unlabeled => _statement.unlabeled; |
| 7429 | 6274 |
| 7430 @override | 6275 @override |
| 7431 accept(AstVisitor visitor) => visitor.visitLabeledStatement(this); | 6276 accept(AstVisitor visitor) => visitor.visitLabeledStatement(this); |
| 7432 | 6277 |
| 7433 @override | 6278 @override |
| 7434 void visitChildren(AstVisitor visitor) { | 6279 void visitChildren(AstVisitor visitor) { |
| 7435 _labels.accept(visitor); | 6280 _labels.accept(visitor); |
| 7436 _safelyVisitChild(_statement, visitor); | 6281 _safelyVisitChild(_statement, visitor); |
| 7437 } | 6282 } |
| 7438 } | 6283 } |
| 7439 | 6284 |
| 7440 /** | 6285 /** |
| 6286 * A label on either a [LabeledStatement] or a [NamedExpression]. |
| 6287 * |
| 6288 * > label ::= |
| 6289 * > [SimpleIdentifier] ':' |
| 6290 */ |
| 6291 class LabelImpl extends AstNodeImpl implements Label { |
| 6292 /** |
| 6293 * The label being associated with the statement. |
| 6294 */ |
| 6295 SimpleIdentifier _label; |
| 6296 |
| 6297 /** |
| 6298 * The colon that separates the label from the statement. |
| 6299 */ |
| 6300 Token colon; |
| 6301 |
| 6302 /** |
| 6303 * Initialize a newly created label. |
| 6304 */ |
| 6305 LabelImpl(SimpleIdentifier label, this.colon) { |
| 6306 _label = _becomeParentOf(label); |
| 6307 } |
| 6308 |
| 6309 @override |
| 6310 Token get beginToken => _label.beginToken; |
| 6311 |
| 6312 @override |
| 6313 Iterable get childEntities => new ChildEntities()..add(_label)..add(colon); |
| 6314 |
| 6315 @override |
| 6316 Token get endToken => colon; |
| 6317 |
| 6318 @override |
| 6319 SimpleIdentifier get label => _label; |
| 6320 |
| 6321 @override |
| 6322 void set label(SimpleIdentifier label) { |
| 6323 _label = _becomeParentOf(label); |
| 6324 } |
| 6325 |
| 6326 @override |
| 6327 accept(AstVisitor visitor) => visitor.visitLabel(this); |
| 6328 |
| 6329 @override |
| 6330 void visitChildren(AstVisitor visitor) { |
| 6331 _safelyVisitChild(_label, visitor); |
| 6332 } |
| 6333 } |
| 6334 |
| 6335 /** |
| 7441 * A library directive. | 6336 * A library directive. |
| 7442 * | 6337 * |
| 7443 * > libraryDirective ::= | 6338 * > libraryDirective ::= |
| 7444 * > [Annotation] 'library' [Identifier] ';' | 6339 * > [Annotation] 'library' [Identifier] ';' |
| 7445 */ | 6340 */ |
| 7446 class LibraryDirective extends Directive { | 6341 class LibraryDirectiveImpl extends DirectiveImpl implements LibraryDirective { |
| 7447 /** | 6342 /** |
| 7448 * The token representing the 'library' keyword. | 6343 * The token representing the 'library' keyword. |
| 7449 */ | 6344 */ |
| 7450 Token libraryKeyword; | 6345 Token libraryKeyword; |
| 7451 | 6346 |
| 7452 /** | 6347 /** |
| 7453 * The name of the library being defined. | 6348 * The name of the library being defined. |
| 7454 */ | 6349 */ |
| 7455 LibraryIdentifier _name; | 6350 LibraryIdentifier _name; |
| 7456 | 6351 |
| 7457 /** | 6352 /** |
| 7458 * The semicolon terminating the directive. | 6353 * The semicolon terminating the directive. |
| 7459 */ | 6354 */ |
| 7460 Token semicolon; | 6355 Token semicolon; |
| 7461 | 6356 |
| 7462 /** | 6357 /** |
| 7463 * Initialize a newly created library directive. Either or both of the | 6358 * Initialize a newly created library directive. Either or both of the |
| 7464 * [comment] and [metadata] can be `null` if the directive does not have the | 6359 * [comment] and [metadata] can be `null` if the directive does not have the |
| 7465 * corresponding attribute. | 6360 * corresponding attribute. |
| 7466 */ | 6361 */ |
| 7467 LibraryDirective(Comment comment, List<Annotation> metadata, | 6362 LibraryDirectiveImpl(Comment comment, List<Annotation> metadata, |
| 7468 this.libraryKeyword, LibraryIdentifier name, this.semicolon) | 6363 this.libraryKeyword, LibraryIdentifier name, this.semicolon) |
| 7469 : super(comment, metadata) { | 6364 : super(comment, metadata) { |
| 7470 _name = _becomeParentOf(name); | 6365 _name = _becomeParentOf(name); |
| 7471 } | 6366 } |
| 7472 | 6367 |
| 7473 @override | 6368 @override |
| 7474 Iterable get childEntities => | 6369 Iterable get childEntities => |
| 7475 super._childEntities..add(libraryKeyword)..add(_name)..add(semicolon); | 6370 super._childEntities..add(libraryKeyword)..add(_name)..add(semicolon); |
| 7476 | 6371 |
| 7477 @override | 6372 @override |
| 7478 Token get endToken => semicolon; | 6373 Token get endToken => semicolon; |
| 7479 | 6374 |
| 7480 @override | 6375 @override |
| 7481 Token get firstTokenAfterCommentAndMetadata => libraryKeyword; | 6376 Token get firstTokenAfterCommentAndMetadata => libraryKeyword; |
| 7482 | 6377 |
| 7483 @override | 6378 @override |
| 7484 Token get keyword => libraryKeyword; | 6379 Token get keyword => libraryKeyword; |
| 7485 | 6380 |
| 7486 /** | 6381 @override |
| 7487 * Return the name of the library being defined. | |
| 7488 */ | |
| 7489 LibraryIdentifier get name => _name; | 6382 LibraryIdentifier get name => _name; |
| 7490 | 6383 |
| 7491 /** | 6384 @override |
| 7492 * Set the name of the library being defined to the given [name]. | |
| 7493 */ | |
| 7494 void set name(LibraryIdentifier name) { | 6385 void set name(LibraryIdentifier name) { |
| 7495 _name = _becomeParentOf(name); | 6386 _name = _becomeParentOf(name); |
| 7496 } | 6387 } |
| 7497 | 6388 |
| 7498 @override | 6389 @override |
| 7499 accept(AstVisitor visitor) => visitor.visitLibraryDirective(this); | 6390 accept(AstVisitor visitor) => visitor.visitLibraryDirective(this); |
| 7500 | 6391 |
| 7501 @override | 6392 @override |
| 7502 void visitChildren(AstVisitor visitor) { | 6393 void visitChildren(AstVisitor visitor) { |
| 7503 super.visitChildren(visitor); | 6394 super.visitChildren(visitor); |
| 7504 _safelyVisitChild(_name, visitor); | 6395 _safelyVisitChild(_name, visitor); |
| 7505 } | 6396 } |
| 7506 } | 6397 } |
| 7507 | 6398 |
| 7508 /** | 6399 /** |
| 7509 * The identifier for a library. | 6400 * The identifier for a library. |
| 7510 * | 6401 * |
| 7511 * > libraryIdentifier ::= | 6402 * > libraryIdentifier ::= |
| 7512 * > [SimpleIdentifier] ('.' [SimpleIdentifier])* | 6403 * > [SimpleIdentifier] ('.' [SimpleIdentifier])* |
| 7513 */ | 6404 */ |
| 7514 class LibraryIdentifier extends Identifier { | 6405 class LibraryIdentifierImpl extends IdentifierImpl |
| 6406 implements LibraryIdentifier { |
| 7515 /** | 6407 /** |
| 7516 * The components of the identifier. | 6408 * The components of the identifier. |
| 7517 */ | 6409 */ |
| 7518 NodeList<SimpleIdentifier> _components; | 6410 NodeList<SimpleIdentifier> _components; |
| 7519 | 6411 |
| 7520 /** | 6412 /** |
| 7521 * Initialize a newly created prefixed identifier. | 6413 * Initialize a newly created prefixed identifier. |
| 7522 */ | 6414 */ |
| 7523 LibraryIdentifier(List<SimpleIdentifier> components) { | 6415 LibraryIdentifierImpl(List<SimpleIdentifier> components) { |
| 7524 _components = new NodeList<SimpleIdentifier>(this, components); | 6416 _components = new NodeList<SimpleIdentifier>(this, components); |
| 7525 } | 6417 } |
| 7526 | 6418 |
| 7527 @override | 6419 @override |
| 7528 Token get beginToken => _components.beginToken; | 6420 Token get beginToken => _components.beginToken; |
| 7529 | 6421 |
| 7530 @override | 6422 @override |
| 7531 Element get bestElement => staticElement; | 6423 Element get bestElement => staticElement; |
| 7532 | 6424 |
| 7533 @override | 6425 @override |
| 7534 // TODO(paulberry): add "." tokens. | 6426 // TODO(paulberry): add "." tokens. |
| 7535 Iterable get childEntities => new ChildEntities()..addAll(_components); | 6427 Iterable get childEntities => new ChildEntities()..addAll(_components); |
| 7536 | 6428 |
| 7537 /** | 6429 @override |
| 7538 * Return the components of the identifier. | |
| 7539 */ | |
| 7540 NodeList<SimpleIdentifier> get components => _components; | 6430 NodeList<SimpleIdentifier> get components => _components; |
| 7541 | 6431 |
| 7542 @override | 6432 @override |
| 7543 Token get endToken => _components.endToken; | 6433 Token get endToken => _components.endToken; |
| 7544 | 6434 |
| 7545 @override | 6435 @override |
| 7546 String get name { | 6436 String get name { |
| 7547 StringBuffer buffer = new StringBuffer(); | 6437 StringBuffer buffer = new StringBuffer(); |
| 7548 bool needsPeriod = false; | 6438 bool needsPeriod = false; |
| 7549 for (SimpleIdentifier identifier in _components) { | 6439 for (SimpleIdentifier identifier in _components) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7574 _components.accept(visitor); | 6464 _components.accept(visitor); |
| 7575 } | 6465 } |
| 7576 } | 6466 } |
| 7577 | 6467 |
| 7578 /** | 6468 /** |
| 7579 * A list literal. | 6469 * A list literal. |
| 7580 * | 6470 * |
| 7581 * > listLiteral ::= | 6471 * > listLiteral ::= |
| 7582 * > 'const'? ('<' [TypeName] '>')? '[' ([Expression] ','?)? ']' | 6472 * > 'const'? ('<' [TypeName] '>')? '[' ([Expression] ','?)? ']' |
| 7583 */ | 6473 */ |
| 7584 class ListLiteral extends TypedLiteral { | 6474 class ListLiteralImpl extends TypedLiteralImpl implements ListLiteral { |
| 7585 /** | 6475 /** |
| 7586 * The left square bracket. | 6476 * The left square bracket. |
| 7587 */ | 6477 */ |
| 7588 Token leftBracket; | 6478 Token leftBracket; |
| 7589 | 6479 |
| 7590 /** | 6480 /** |
| 7591 * The expressions used to compute the elements of the list. | 6481 * The expressions used to compute the elements of the list. |
| 7592 */ | 6482 */ |
| 7593 NodeList<Expression> _elements; | 6483 NodeList<Expression> _elements; |
| 7594 | 6484 |
| 7595 /** | 6485 /** |
| 7596 * The right square bracket. | 6486 * The right square bracket. |
| 7597 */ | 6487 */ |
| 7598 Token rightBracket; | 6488 Token rightBracket; |
| 7599 | 6489 |
| 7600 /** | 6490 /** |
| 7601 * Initialize a newly created list literal. The [constKeyword] can be `null` | 6491 * Initialize a newly created list literal. The [constKeyword] can be `null` |
| 7602 * if the literal is not a constant. The [typeArguments] can be `null` if no | 6492 * if the literal is not a constant. The [typeArguments] can be `null` if no |
| 7603 * type arguments were declared. The list of [elements] can be `null` if the | 6493 * type arguments were declared. The list of [elements] can be `null` if the |
| 7604 * list is empty. | 6494 * list is empty. |
| 7605 */ | 6495 */ |
| 7606 ListLiteral(Token constKeyword, TypeArgumentList typeArguments, | 6496 ListLiteralImpl(Token constKeyword, TypeArgumentList typeArguments, |
| 7607 this.leftBracket, List<Expression> elements, this.rightBracket) | 6497 this.leftBracket, List<Expression> elements, this.rightBracket) |
| 7608 : super(constKeyword, typeArguments) { | 6498 : super(constKeyword, typeArguments) { |
| 7609 _elements = new NodeList<Expression>(this, elements); | 6499 _elements = new NodeList<Expression>(this, elements); |
| 7610 } | 6500 } |
| 7611 | 6501 |
| 7612 @override | 6502 @override |
| 7613 Token get beginToken { | 6503 Token get beginToken { |
| 7614 if (constKeyword != null) { | 6504 if (constKeyword != null) { |
| 7615 return constKeyword; | 6505 return constKeyword; |
| 7616 } | 6506 } |
| 7617 TypeArgumentList typeArguments = this.typeArguments; | 6507 TypeArgumentList typeArguments = this.typeArguments; |
| 7618 if (typeArguments != null) { | 6508 if (typeArguments != null) { |
| 7619 return typeArguments.beginToken; | 6509 return typeArguments.beginToken; |
| 7620 } | 6510 } |
| 7621 return leftBracket; | 6511 return leftBracket; |
| 7622 } | 6512 } |
| 7623 | 6513 |
| 7624 @override | 6514 @override |
| 7625 // TODO(paulberry): add commas. | 6515 // TODO(paulberry): add commas. |
| 7626 Iterable get childEntities => super._childEntities | 6516 Iterable get childEntities => super._childEntities |
| 7627 ..add(leftBracket) | 6517 ..add(leftBracket) |
| 7628 ..addAll(_elements) | 6518 ..addAll(_elements) |
| 7629 ..add(rightBracket); | 6519 ..add(rightBracket); |
| 7630 | 6520 |
| 7631 /** | 6521 @override |
| 7632 * Return the expressions used to compute the elements of the list. | |
| 7633 */ | |
| 7634 NodeList<Expression> get elements => _elements; | 6522 NodeList<Expression> get elements => _elements; |
| 7635 | 6523 |
| 7636 @override | 6524 @override |
| 7637 Token get endToken => rightBracket; | 6525 Token get endToken => rightBracket; |
| 7638 | 6526 |
| 7639 @override | 6527 @override |
| 7640 accept(AstVisitor visitor) => visitor.visitListLiteral(this); | 6528 accept(AstVisitor visitor) => visitor.visitListLiteral(this); |
| 7641 | 6529 |
| 7642 @override | 6530 @override |
| 7643 void visitChildren(AstVisitor visitor) { | 6531 void visitChildren(AstVisitor visitor) { |
| 7644 super.visitChildren(visitor); | 6532 super.visitChildren(visitor); |
| 7645 _elements.accept(visitor); | 6533 _elements.accept(visitor); |
| 7646 } | 6534 } |
| 7647 } | 6535 } |
| 7648 | 6536 |
| 7649 /** | 6537 /** |
| 7650 * A node that represents a literal expression. | 6538 * A node that represents a literal expression. |
| 7651 * | 6539 * |
| 7652 * > literal ::= | 6540 * > literal ::= |
| 7653 * > [BooleanLiteral] | 6541 * > [BooleanLiteral] |
| 7654 * > | [DoubleLiteral] | 6542 * > | [DoubleLiteral] |
| 7655 * > | [IntegerLiteral] | 6543 * > | [IntegerLiteral] |
| 7656 * > | [ListLiteral] | 6544 * > | [ListLiteral] |
| 7657 * > | [MapLiteral] | 6545 * > | [MapLiteral] |
| 7658 * > | [NullLiteral] | 6546 * > | [NullLiteral] |
| 7659 * > | [StringLiteral] | 6547 * > | [StringLiteral] |
| 7660 */ | 6548 */ |
| 7661 abstract class Literal extends Expression { | 6549 abstract class LiteralImpl extends ExpressionImpl implements Literal { |
| 7662 @override | 6550 @override |
| 7663 int get precedence => 16; | 6551 int get precedence => 16; |
| 7664 } | 6552 } |
| 7665 | 6553 |
| 7666 /** | 6554 /** |
| 6555 * A single key/value pair in a map literal. |
| 6556 * |
| 6557 * > mapLiteralEntry ::= |
| 6558 * > [Expression] ':' [Expression] |
| 6559 */ |
| 6560 class MapLiteralEntryImpl extends AstNodeImpl implements MapLiteralEntry { |
| 6561 /** |
| 6562 * The expression computing the key with which the value will be associated. |
| 6563 */ |
| 6564 Expression _key; |
| 6565 |
| 6566 /** |
| 6567 * The colon that separates the key from the value. |
| 6568 */ |
| 6569 Token separator; |
| 6570 |
| 6571 /** |
| 6572 * The expression computing the value that will be associated with the key. |
| 6573 */ |
| 6574 Expression _value; |
| 6575 |
| 6576 /** |
| 6577 * Initialize a newly created map literal entry. |
| 6578 */ |
| 6579 MapLiteralEntryImpl(Expression key, this.separator, Expression value) { |
| 6580 _key = _becomeParentOf(key); |
| 6581 _value = _becomeParentOf(value); |
| 6582 } |
| 6583 |
| 6584 @override |
| 6585 Token get beginToken => _key.beginToken; |
| 6586 |
| 6587 @override |
| 6588 Iterable get childEntities => |
| 6589 new ChildEntities()..add(_key)..add(separator)..add(_value); |
| 6590 |
| 6591 @override |
| 6592 Token get endToken => _value.endToken; |
| 6593 |
| 6594 @override |
| 6595 Expression get key => _key; |
| 6596 |
| 6597 @override |
| 6598 void set key(Expression string) { |
| 6599 _key = _becomeParentOf(string); |
| 6600 } |
| 6601 |
| 6602 @override |
| 6603 Expression get value => _value; |
| 6604 |
| 6605 @override |
| 6606 void set value(Expression expression) { |
| 6607 _value = _becomeParentOf(expression); |
| 6608 } |
| 6609 |
| 6610 @override |
| 6611 accept(AstVisitor visitor) => visitor.visitMapLiteralEntry(this); |
| 6612 |
| 6613 @override |
| 6614 void visitChildren(AstVisitor visitor) { |
| 6615 _safelyVisitChild(_key, visitor); |
| 6616 _safelyVisitChild(_value, visitor); |
| 6617 } |
| 6618 } |
| 6619 |
| 6620 /** |
| 7667 * A literal map. | 6621 * A literal map. |
| 7668 * | 6622 * |
| 7669 * > mapLiteral ::= | 6623 * > mapLiteral ::= |
| 7670 * > 'const'? ('<' [TypeName] (',' [TypeName])* '>')? | 6624 * > 'const'? ('<' [TypeName] (',' [TypeName])* '>')? |
| 7671 * > '{' ([MapLiteralEntry] (',' [MapLiteralEntry])* ','?)? '}' | 6625 * > '{' ([MapLiteralEntry] (',' [MapLiteralEntry])* ','?)? '}' |
| 7672 */ | 6626 */ |
| 7673 class MapLiteral extends TypedLiteral { | 6627 class MapLiteralImpl extends TypedLiteralImpl implements MapLiteral { |
| 7674 /** | 6628 /** |
| 7675 * The left curly bracket. | 6629 * The left curly bracket. |
| 7676 */ | 6630 */ |
| 7677 Token leftBracket; | 6631 Token leftBracket; |
| 7678 | 6632 |
| 7679 /** | 6633 /** |
| 7680 * The entries in the map. | 6634 * The entries in the map. |
| 7681 */ | 6635 */ |
| 7682 NodeList<MapLiteralEntry> _entries; | 6636 NodeList<MapLiteralEntry> _entries; |
| 7683 | 6637 |
| 7684 /** | 6638 /** |
| 7685 * The right curly bracket. | 6639 * The right curly bracket. |
| 7686 */ | 6640 */ |
| 7687 Token rightBracket; | 6641 Token rightBracket; |
| 7688 | 6642 |
| 7689 /** | 6643 /** |
| 7690 * Initialize a newly created map literal. The [constKeyword] can be `null` if | 6644 * Initialize a newly created map literal. The [constKeyword] can be `null` if |
| 7691 * the literal is not a constant. The [typeArguments] can be `null` if no type | 6645 * the literal is not a constant. The [typeArguments] can be `null` if no type |
| 7692 * arguments were declared. The [entries] can be `null` if the map is empty. | 6646 * arguments were declared. The [entries] can be `null` if the map is empty. |
| 7693 */ | 6647 */ |
| 7694 MapLiteral(Token constKeyword, TypeArgumentList typeArguments, | 6648 MapLiteralImpl(Token constKeyword, TypeArgumentList typeArguments, |
| 7695 this.leftBracket, List<MapLiteralEntry> entries, this.rightBracket) | 6649 this.leftBracket, List<MapLiteralEntry> entries, this.rightBracket) |
| 7696 : super(constKeyword, typeArguments) { | 6650 : super(constKeyword, typeArguments) { |
| 7697 _entries = new NodeList<MapLiteralEntry>(this, entries); | 6651 _entries = new NodeList<MapLiteralEntry>(this, entries); |
| 7698 } | 6652 } |
| 7699 | 6653 |
| 7700 @override | 6654 @override |
| 7701 Token get beginToken { | 6655 Token get beginToken { |
| 7702 if (constKeyword != null) { | 6656 if (constKeyword != null) { |
| 7703 return constKeyword; | 6657 return constKeyword; |
| 7704 } | 6658 } |
| 7705 TypeArgumentList typeArguments = this.typeArguments; | 6659 TypeArgumentList typeArguments = this.typeArguments; |
| 7706 if (typeArguments != null) { | 6660 if (typeArguments != null) { |
| 7707 return typeArguments.beginToken; | 6661 return typeArguments.beginToken; |
| 7708 } | 6662 } |
| 7709 return leftBracket; | 6663 return leftBracket; |
| 7710 } | 6664 } |
| 7711 | 6665 |
| 7712 @override | 6666 @override |
| 7713 // TODO(paulberry): add commas. | 6667 // TODO(paulberry): add commas. |
| 7714 Iterable get childEntities => super._childEntities | 6668 Iterable get childEntities => super._childEntities |
| 7715 ..add(leftBracket) | 6669 ..add(leftBracket) |
| 7716 ..addAll(entries) | 6670 ..addAll(entries) |
| 7717 ..add(rightBracket); | 6671 ..add(rightBracket); |
| 7718 | 6672 |
| 7719 @override | 6673 @override |
| 7720 Token get endToken => rightBracket; | 6674 Token get endToken => rightBracket; |
| 7721 | 6675 |
| 7722 /** | 6676 @override |
| 7723 * Return the entries in the map. | |
| 7724 */ | |
| 7725 NodeList<MapLiteralEntry> get entries => _entries; | 6677 NodeList<MapLiteralEntry> get entries => _entries; |
| 7726 | 6678 |
| 7727 @override | 6679 @override |
| 7728 accept(AstVisitor visitor) => visitor.visitMapLiteral(this); | 6680 accept(AstVisitor visitor) => visitor.visitMapLiteral(this); |
| 7729 | 6681 |
| 7730 @override | 6682 @override |
| 7731 void visitChildren(AstVisitor visitor) { | 6683 void visitChildren(AstVisitor visitor) { |
| 7732 super.visitChildren(visitor); | 6684 super.visitChildren(visitor); |
| 7733 _entries.accept(visitor); | 6685 _entries.accept(visitor); |
| 7734 } | 6686 } |
| 7735 } | 6687 } |
| 7736 | 6688 |
| 7737 /** | |
| 7738 * A single key/value pair in a map literal. | |
| 7739 * | |
| 7740 * > mapLiteralEntry ::= | |
| 7741 * > [Expression] ':' [Expression] | |
| 7742 */ | |
| 7743 class MapLiteralEntry extends AstNode { | |
| 7744 /** | |
| 7745 * The expression computing the key with which the value will be associated. | |
| 7746 */ | |
| 7747 Expression _key; | |
| 7748 | |
| 7749 /** | |
| 7750 * The colon that separates the key from the value. | |
| 7751 */ | |
| 7752 Token separator; | |
| 7753 | |
| 7754 /** | |
| 7755 * The expression computing the value that will be associated with the key. | |
| 7756 */ | |
| 7757 Expression _value; | |
| 7758 | |
| 7759 /** | |
| 7760 * Initialize a newly created map literal entry. | |
| 7761 */ | |
| 7762 MapLiteralEntry(Expression key, this.separator, Expression value) { | |
| 7763 _key = _becomeParentOf(key); | |
| 7764 _value = _becomeParentOf(value); | |
| 7765 } | |
| 7766 | |
| 7767 @override | |
| 7768 Token get beginToken => _key.beginToken; | |
| 7769 | |
| 7770 @override | |
| 7771 Iterable get childEntities => | |
| 7772 new ChildEntities()..add(_key)..add(separator)..add(_value); | |
| 7773 | |
| 7774 @override | |
| 7775 Token get endToken => _value.endToken; | |
| 7776 | |
| 7777 /** | |
| 7778 * Return the expression computing the key with which the value will be | |
| 7779 * associated. | |
| 7780 */ | |
| 7781 Expression get key => _key; | |
| 7782 | |
| 7783 /** | |
| 7784 * Set the expression computing the key with which the value will be | |
| 7785 * associated to the given [string]. | |
| 7786 */ | |
| 7787 void set key(Expression string) { | |
| 7788 _key = _becomeParentOf(string); | |
| 7789 } | |
| 7790 | |
| 7791 /** | |
| 7792 * Return the expression computing the value that will be associated with the | |
| 7793 * key. | |
| 7794 */ | |
| 7795 Expression get value => _value; | |
| 7796 | |
| 7797 /** | |
| 7798 * Set the expression computing the value that will be associated with the key | |
| 7799 * to the given [expression]. | |
| 7800 */ | |
| 7801 void set value(Expression expression) { | |
| 7802 _value = _becomeParentOf(expression); | |
| 7803 } | |
| 7804 | |
| 7805 @override | |
| 7806 accept(AstVisitor visitor) => visitor.visitMapLiteralEntry(this); | |
| 7807 | |
| 7808 @override | |
| 7809 void visitChildren(AstVisitor visitor) { | |
| 7810 _safelyVisitChild(_key, visitor); | |
| 7811 _safelyVisitChild(_value, visitor); | |
| 7812 } | |
| 7813 } | |
| 7814 | |
| 7815 /** | 6689 /** |
| 7816 * A method declaration. | 6690 * A method declaration. |
| 7817 * | 6691 * |
| 7818 * > methodDeclaration ::= | 6692 * > methodDeclaration ::= |
| 7819 * > methodSignature [FunctionBody] | 6693 * > methodSignature [FunctionBody] |
| 7820 * > | 6694 * > |
| 7821 * > methodSignature ::= | 6695 * > methodSignature ::= |
| 7822 * > 'external'? ('abstract' | 'static')? [Type]? ('get' | 'set')? | 6696 * > 'external'? ('abstract' | 'static')? [Type]? ('get' | 'set')? |
| 7823 * > methodName [TypeParameterList] [FormalParameterList] | 6697 * > methodName [TypeParameterList] [FormalParameterList] |
| 7824 * > | 6698 * > |
| 7825 * > methodName ::= | 6699 * > methodName ::= |
| 7826 * > [SimpleIdentifier] | 6700 * > [SimpleIdentifier] |
| 7827 * > | 'operator' [SimpleIdentifier] | 6701 * > | 'operator' [SimpleIdentifier] |
| 7828 */ | 6702 */ |
| 7829 class MethodDeclaration extends ClassMember { | 6703 class MethodDeclarationImpl extends ClassMemberImpl |
| 6704 implements MethodDeclaration { |
| 7830 /** | 6705 /** |
| 7831 * The token for the 'external' keyword, or `null` if the constructor is not | 6706 * The token for the 'external' keyword, or `null` if the constructor is not |
| 7832 * external. | 6707 * external. |
| 7833 */ | 6708 */ |
| 7834 Token externalKeyword; | 6709 Token externalKeyword; |
| 7835 | 6710 |
| 7836 /** | 6711 /** |
| 7837 * The token representing the 'abstract' or 'static' keyword, or `null` if | 6712 * The token representing the 'abstract' or 'static' keyword, or `null` if |
| 7838 * neither modifier was specified. | 6713 * neither modifier was specified. |
| 7839 */ | 6714 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7882 * Initialize a newly created method declaration. Either or both of the | 6757 * Initialize a newly created method declaration. Either or both of the |
| 7883 * [comment] and [metadata] can be `null` if the declaration does not have the | 6758 * [comment] and [metadata] can be `null` if the declaration does not have the |
| 7884 * corresponding attribute. The [externalKeyword] can be `null` if the method | 6759 * corresponding attribute. The [externalKeyword] can be `null` if the method |
| 7885 * is not external. The [modifierKeyword] can be `null` if the method is | 6760 * is not external. The [modifierKeyword] can be `null` if the method is |
| 7886 * neither abstract nor static. The [returnType] can be `null` if no return | 6761 * neither abstract nor static. The [returnType] can be `null` if no return |
| 7887 * type was specified. The [propertyKeyword] can be `null` if the method is | 6762 * type was specified. The [propertyKeyword] can be `null` if the method is |
| 7888 * neither a getter or a setter. The [operatorKeyword] can be `null` if the | 6763 * neither a getter or a setter. The [operatorKeyword] can be `null` if the |
| 7889 * method does not implement an operator. The [parameters] must be `null` if | 6764 * method does not implement an operator. The [parameters] must be `null` if |
| 7890 * this method declares a getter. | 6765 * this method declares a getter. |
| 7891 */ | 6766 */ |
| 7892 MethodDeclaration( | 6767 MethodDeclarationImpl( |
| 7893 Comment comment, | 6768 Comment comment, |
| 7894 List<Annotation> metadata, | 6769 List<Annotation> metadata, |
| 7895 this.externalKeyword, | 6770 this.externalKeyword, |
| 7896 this.modifierKeyword, | 6771 this.modifierKeyword, |
| 7897 TypeName returnType, | 6772 TypeName returnType, |
| 7898 this.propertyKeyword, | 6773 this.propertyKeyword, |
| 7899 this.operatorKeyword, | 6774 this.operatorKeyword, |
| 7900 SimpleIdentifier name, | 6775 SimpleIdentifier name, |
| 7901 TypeParameterList typeParameters, | 6776 TypeParameterList typeParameters, |
| 7902 FormalParameterList parameters, | 6777 FormalParameterList parameters, |
| 7903 FunctionBody body) | 6778 FunctionBody body) |
| 7904 : super(comment, metadata) { | 6779 : super(comment, metadata) { |
| 7905 _returnType = _becomeParentOf(returnType); | 6780 _returnType = _becomeParentOf(returnType); |
| 7906 _name = _becomeParentOf(name); | 6781 _name = _becomeParentOf(name); |
| 7907 _typeParameters = _becomeParentOf(typeParameters); | 6782 _typeParameters = _becomeParentOf(typeParameters); |
| 7908 _parameters = _becomeParentOf(parameters); | 6783 _parameters = _becomeParentOf(parameters); |
| 7909 _body = _becomeParentOf(body); | 6784 _body = _becomeParentOf(body); |
| 7910 } | 6785 } |
| 7911 | 6786 |
| 7912 /** | 6787 @override |
| 7913 * Return the body of the method. | |
| 7914 */ | |
| 7915 FunctionBody get body => _body; | 6788 FunctionBody get body => _body; |
| 7916 | 6789 |
| 7917 /** | 6790 @override |
| 7918 * Set the body of the method to the given [functionBody]. | |
| 7919 */ | |
| 7920 void set body(FunctionBody functionBody) { | 6791 void set body(FunctionBody functionBody) { |
| 7921 _body = _becomeParentOf(functionBody); | 6792 _body = _becomeParentOf(functionBody); |
| 7922 } | 6793 } |
| 7923 | 6794 |
| 7924 @override | 6795 @override |
| 7925 Iterable get childEntities => super._childEntities | 6796 Iterable get childEntities => super._childEntities |
| 7926 ..add(externalKeyword) | 6797 ..add(externalKeyword) |
| 7927 ..add(modifierKeyword) | 6798 ..add(modifierKeyword) |
| 7928 ..add(_returnType) | 6799 ..add(_returnType) |
| 7929 ..add(propertyKeyword) | 6800 ..add(propertyKeyword) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7953 } else if (_returnType != null) { | 6824 } else if (_returnType != null) { |
| 7954 return _returnType.beginToken; | 6825 return _returnType.beginToken; |
| 7955 } else if (propertyKeyword != null) { | 6826 } else if (propertyKeyword != null) { |
| 7956 return propertyKeyword; | 6827 return propertyKeyword; |
| 7957 } else if (operatorKeyword != null) { | 6828 } else if (operatorKeyword != null) { |
| 7958 return operatorKeyword; | 6829 return operatorKeyword; |
| 7959 } | 6830 } |
| 7960 return _name.beginToken; | 6831 return _name.beginToken; |
| 7961 } | 6832 } |
| 7962 | 6833 |
| 7963 /** | 6834 @override |
| 7964 * Return `true` if this method is declared to be an abstract method. | |
| 7965 */ | |
| 7966 bool get isAbstract { | 6835 bool get isAbstract { |
| 7967 FunctionBody body = _body; | 6836 FunctionBody body = _body; |
| 7968 return externalKeyword == null && | 6837 return externalKeyword == null && |
| 7969 (body is EmptyFunctionBody && !body.semicolon.isSynthetic); | 6838 (body is EmptyFunctionBody && !body.semicolon.isSynthetic); |
| 7970 } | 6839 } |
| 7971 | 6840 |
| 7972 /** | 6841 @override |
| 7973 * Return `true` if this method declares a getter. | |
| 7974 */ | |
| 7975 bool get isGetter => | 6842 bool get isGetter => |
| 7976 propertyKeyword != null && | 6843 propertyKeyword != null && |
| 7977 (propertyKeyword as KeywordToken).keyword == Keyword.GET; | 6844 (propertyKeyword as KeywordToken).keyword == Keyword.GET; |
| 7978 | 6845 |
| 7979 /** | 6846 @override |
| 7980 * Return `true` if this method declares an operator. | |
| 7981 */ | |
| 7982 bool get isOperator => operatorKeyword != null; | 6847 bool get isOperator => operatorKeyword != null; |
| 7983 | 6848 |
| 7984 /** | 6849 @override |
| 7985 * Return `true` if this method declares a setter. | |
| 7986 */ | |
| 7987 bool get isSetter => | 6850 bool get isSetter => |
| 7988 propertyKeyword != null && | 6851 propertyKeyword != null && |
| 7989 (propertyKeyword as KeywordToken).keyword == Keyword.SET; | 6852 (propertyKeyword as KeywordToken).keyword == Keyword.SET; |
| 7990 | 6853 |
| 7991 /** | 6854 @override |
| 7992 * Return `true` if this method is declared to be a static method. | |
| 7993 */ | |
| 7994 bool get isStatic => | 6855 bool get isStatic => |
| 7995 modifierKeyword != null && | 6856 modifierKeyword != null && |
| 7996 (modifierKeyword as KeywordToken).keyword == Keyword.STATIC; | 6857 (modifierKeyword as KeywordToken).keyword == Keyword.STATIC; |
| 7997 | 6858 |
| 7998 /** | 6859 @override |
| 7999 * Return the name of the method. | |
| 8000 */ | |
| 8001 SimpleIdentifier get name => _name; | 6860 SimpleIdentifier get name => _name; |
| 8002 | 6861 |
| 8003 /** | 6862 @override |
| 8004 * Set the name of the method to the given [identifier]. | |
| 8005 */ | |
| 8006 void set name(SimpleIdentifier identifier) { | 6863 void set name(SimpleIdentifier identifier) { |
| 8007 _name = _becomeParentOf(identifier); | 6864 _name = _becomeParentOf(identifier); |
| 8008 } | 6865 } |
| 8009 | 6866 |
| 8010 /** | 6867 @override |
| 8011 * Return the parameters associated with the method, or `null` if this method | |
| 8012 * declares a getter. | |
| 8013 */ | |
| 8014 FormalParameterList get parameters => _parameters; | 6868 FormalParameterList get parameters => _parameters; |
| 8015 | 6869 |
| 8016 /** | 6870 @override |
| 8017 * Set the parameters associated with the method to the given list of | |
| 8018 * [parameters]. | |
| 8019 */ | |
| 8020 void set parameters(FormalParameterList parameters) { | 6871 void set parameters(FormalParameterList parameters) { |
| 8021 _parameters = _becomeParentOf(parameters); | 6872 _parameters = _becomeParentOf(parameters); |
| 8022 } | 6873 } |
| 8023 | 6874 |
| 8024 /** | 6875 @override |
| 8025 * Return the return type of the method, or `null` if no return type was | |
| 8026 * declared. | |
| 8027 */ | |
| 8028 TypeName get returnType => _returnType; | 6876 TypeName get returnType => _returnType; |
| 8029 | 6877 |
| 8030 /** | 6878 @override |
| 8031 * Set the return type of the method to the given [typeName]. | |
| 8032 */ | |
| 8033 void set returnType(TypeName typeName) { | 6879 void set returnType(TypeName typeName) { |
| 8034 _returnType = _becomeParentOf(typeName); | 6880 _returnType = _becomeParentOf(typeName); |
| 8035 } | 6881 } |
| 8036 | 6882 |
| 8037 /** | 6883 @override |
| 8038 * Return the type parameters associated with this method, or `null` if this | |
| 8039 * method is not a generic method. | |
| 8040 */ | |
| 8041 TypeParameterList get typeParameters => _typeParameters; | 6884 TypeParameterList get typeParameters => _typeParameters; |
| 8042 | 6885 |
| 8043 /** | 6886 @override |
| 8044 * Set the type parameters associated with this method to the given | |
| 8045 * [typeParameters]. | |
| 8046 */ | |
| 8047 void set typeParameters(TypeParameterList typeParameters) { | 6887 void set typeParameters(TypeParameterList typeParameters) { |
| 8048 _typeParameters = _becomeParentOf(typeParameters); | 6888 _typeParameters = _becomeParentOf(typeParameters); |
| 8049 } | 6889 } |
| 8050 | 6890 |
| 8051 @override | 6891 @override |
| 8052 accept(AstVisitor visitor) => visitor.visitMethodDeclaration(this); | 6892 accept(AstVisitor visitor) => visitor.visitMethodDeclaration(this); |
| 8053 | 6893 |
| 8054 @override | 6894 @override |
| 8055 void visitChildren(AstVisitor visitor) { | 6895 void visitChildren(AstVisitor visitor) { |
| 8056 super.visitChildren(visitor); | 6896 super.visitChildren(visitor); |
| 8057 _safelyVisitChild(_returnType, visitor); | 6897 _safelyVisitChild(_returnType, visitor); |
| 8058 _safelyVisitChild(_name, visitor); | 6898 _safelyVisitChild(_name, visitor); |
| 8059 _safelyVisitChild(_typeParameters, visitor); | 6899 _safelyVisitChild(_typeParameters, visitor); |
| 8060 _safelyVisitChild(_parameters, visitor); | 6900 _safelyVisitChild(_parameters, visitor); |
| 8061 _safelyVisitChild(_body, visitor); | 6901 _safelyVisitChild(_body, visitor); |
| 8062 } | 6902 } |
| 8063 } | 6903 } |
| 8064 | 6904 |
| 8065 /** | 6905 /** |
| 8066 * The invocation of either a function or a method. Invocations of functions | 6906 * The invocation of either a function or a method. Invocations of functions |
| 8067 * resulting from evaluating an expression are represented by | 6907 * resulting from evaluating an expression are represented by |
| 8068 * [FunctionExpressionInvocation] nodes. Invocations of getters and setters are | 6908 * [FunctionExpressionInvocation] nodes. Invocations of getters and setters are |
| 8069 * represented by either [PrefixedIdentifier] or [PropertyAccess] nodes. | 6909 * represented by either [PrefixedIdentifier] or [PropertyAccess] nodes. |
| 8070 * | 6910 * |
| 8071 * > methodInvocation ::= | 6911 * > methodInvocation ::= |
| 8072 * > ([Expression] '.')? [SimpleIdentifier] [TypeArgumentList]? [ArgumentLis
t] | 6912 * > ([Expression] '.')? [SimpleIdentifier] [TypeArgumentList]? [ArgumentLis
t] |
| 8073 */ | 6913 */ |
| 8074 class MethodInvocation extends Expression { | 6914 class MethodInvocationImpl extends ExpressionImpl implements MethodInvocation { |
| 8075 /** | 6915 /** |
| 8076 * The expression producing the object on which the method is defined, or | 6916 * The expression producing the object on which the method is defined, or |
| 8077 * `null` if there is no target (that is, the target is implicitly `this`). | 6917 * `null` if there is no target (that is, the target is implicitly `this`). |
| 8078 */ | 6918 */ |
| 8079 Expression _target; | 6919 Expression _target; |
| 8080 | 6920 |
| 8081 /** | 6921 /** |
| 8082 * The operator that separates the target from the method name, or `null` | 6922 * The operator that separates the target from the method name, or `null` |
| 8083 * if there is no target. In an ordinary method invocation this will be a | 6923 * if there is no target. In an ordinary method invocation this will be a |
| 8084 * period ('.'). In a cascade section this will be the cascade operator | 6924 * period ('.'). In a cascade section this will be the cascade operator |
| (...skipping 29 matching lines...) Expand all Loading... |
| 8114 | 6954 |
| 8115 /** | 6955 /** |
| 8116 * Like [staticInvokeType], but reflects propagated type information. | 6956 * Like [staticInvokeType], but reflects propagated type information. |
| 8117 */ | 6957 */ |
| 8118 DartType propagatedInvokeType; | 6958 DartType propagatedInvokeType; |
| 8119 | 6959 |
| 8120 /** | 6960 /** |
| 8121 * Initialize a newly created method invocation. The [target] and [operator] | 6961 * Initialize a newly created method invocation. The [target] and [operator] |
| 8122 * can be `null` if there is no target. | 6962 * can be `null` if there is no target. |
| 8123 */ | 6963 */ |
| 8124 MethodInvocation( | 6964 MethodInvocationImpl( |
| 8125 Expression target, | 6965 Expression target, |
| 8126 this.operator, | 6966 this.operator, |
| 8127 SimpleIdentifier methodName, | 6967 SimpleIdentifier methodName, |
| 8128 TypeArgumentList typeArguments, | 6968 TypeArgumentList typeArguments, |
| 8129 ArgumentList argumentList) { | 6969 ArgumentList argumentList) { |
| 8130 _target = _becomeParentOf(target); | 6970 _target = _becomeParentOf(target); |
| 8131 _methodName = _becomeParentOf(methodName); | 6971 _methodName = _becomeParentOf(methodName); |
| 8132 _typeArguments = _becomeParentOf(typeArguments); | 6972 _typeArguments = _becomeParentOf(typeArguments); |
| 8133 _argumentList = _becomeParentOf(argumentList); | 6973 _argumentList = _becomeParentOf(argumentList); |
| 8134 } | 6974 } |
| 8135 | 6975 |
| 8136 /** | 6976 @override |
| 8137 * Return the list of arguments to the method. | |
| 8138 */ | |
| 8139 ArgumentList get argumentList => _argumentList; | 6977 ArgumentList get argumentList => _argumentList; |
| 8140 | 6978 |
| 8141 /** | 6979 @override |
| 8142 * Set the list of arguments to the method to the given [argumentList]. | |
| 8143 */ | |
| 8144 void set argumentList(ArgumentList argumentList) { | 6980 void set argumentList(ArgumentList argumentList) { |
| 8145 _argumentList = _becomeParentOf(argumentList); | 6981 _argumentList = _becomeParentOf(argumentList); |
| 8146 } | 6982 } |
| 8147 | 6983 |
| 8148 @override | 6984 @override |
| 8149 Token get beginToken { | 6985 Token get beginToken { |
| 8150 if (_target != null) { | 6986 if (_target != null) { |
| 8151 return _target.beginToken; | 6987 return _target.beginToken; |
| 8152 } else if (operator != null) { | 6988 } else if (operator != null) { |
| 8153 return operator; | 6989 return operator; |
| 8154 } | 6990 } |
| 8155 return _methodName.beginToken; | 6991 return _methodName.beginToken; |
| 8156 } | 6992 } |
| 8157 | 6993 |
| 8158 @override | 6994 @override |
| 8159 Iterable get childEntities => new ChildEntities() | 6995 Iterable get childEntities => new ChildEntities() |
| 8160 ..add(_target) | 6996 ..add(_target) |
| 8161 ..add(operator) | 6997 ..add(operator) |
| 8162 ..add(_methodName) | 6998 ..add(_methodName) |
| 8163 ..add(_argumentList); | 6999 ..add(_argumentList); |
| 8164 | 7000 |
| 8165 @override | 7001 @override |
| 8166 Token get endToken => _argumentList.endToken; | 7002 Token get endToken => _argumentList.endToken; |
| 8167 | 7003 |
| 8168 /** | 7004 @override |
| 8169 * Return `true` if this expression is cascaded. If it is, then the target of | |
| 8170 * this expression is not stored locally but is stored in the nearest ancestor | |
| 8171 * that is a [CascadeExpression]. | |
| 8172 */ | |
| 8173 bool get isCascaded => | 7005 bool get isCascaded => |
| 8174 operator != null && operator.type == TokenType.PERIOD_PERIOD; | 7006 operator != null && operator.type == TokenType.PERIOD_PERIOD; |
| 8175 | 7007 |
| 8176 /** | 7008 @override |
| 8177 * Return the name of the method being invoked. | |
| 8178 */ | |
| 8179 SimpleIdentifier get methodName => _methodName; | 7009 SimpleIdentifier get methodName => _methodName; |
| 8180 | 7010 |
| 8181 /** | 7011 @override |
| 8182 * Set the name of the method being invoked to the given [identifier]. | |
| 8183 */ | |
| 8184 void set methodName(SimpleIdentifier identifier) { | 7012 void set methodName(SimpleIdentifier identifier) { |
| 8185 _methodName = _becomeParentOf(identifier); | 7013 _methodName = _becomeParentOf(identifier); |
| 8186 } | 7014 } |
| 8187 | 7015 |
| 8188 @override | 7016 @override |
| 8189 int get precedence => 15; | 7017 int get precedence => 15; |
| 8190 | 7018 |
| 8191 /** | 7019 @override |
| 8192 * Return the expression used to compute the receiver of the invocation. If | |
| 8193 * this invocation is not part of a cascade expression, then this is the same | |
| 8194 * as [target]. If this invocation is part of a cascade expression, then the | |
| 8195 * target stored with the cascade expression is returned. | |
| 8196 */ | |
| 8197 Expression get realTarget { | 7020 Expression get realTarget { |
| 8198 if (isCascaded) { | 7021 if (isCascaded) { |
| 8199 AstNode ancestor = parent; | 7022 AstNode ancestor = parent; |
| 8200 while (ancestor is! CascadeExpression) { | 7023 while (ancestor is! CascadeExpression) { |
| 8201 if (ancestor == null) { | 7024 if (ancestor == null) { |
| 8202 return _target; | 7025 return _target; |
| 8203 } | 7026 } |
| 8204 ancestor = ancestor.parent; | 7027 ancestor = ancestor.parent; |
| 8205 } | 7028 } |
| 8206 return (ancestor as CascadeExpression).target; | 7029 return (ancestor as CascadeExpression).target; |
| 8207 } | 7030 } |
| 8208 return _target; | 7031 return _target; |
| 8209 } | 7032 } |
| 8210 | 7033 |
| 8211 /** | 7034 @override |
| 8212 * Return the expression producing the object on which the method is defined, | |
| 8213 * or `null` if there is no target (that is, the target is implicitly `this`) | |
| 8214 * or if this method invocation is part of a cascade expression. | |
| 8215 * | |
| 8216 * Use [realTarget] to get the target independent of whether this is part of a | |
| 8217 * cascade expression. | |
| 8218 */ | |
| 8219 Expression get target => _target; | 7035 Expression get target => _target; |
| 8220 | 7036 |
| 8221 /** | 7037 @override |
| 8222 * Set the expression producing the object on which the method is defined to | |
| 8223 * the given [expression]. | |
| 8224 */ | |
| 8225 void set target(Expression expression) { | 7038 void set target(Expression expression) { |
| 8226 _target = _becomeParentOf(expression); | 7039 _target = _becomeParentOf(expression); |
| 8227 } | 7040 } |
| 8228 | 7041 |
| 8229 /** | 7042 @override |
| 8230 * Return the type arguments to be applied to the method being invoked, or | |
| 8231 * `null` if no type arguments were provided. | |
| 8232 */ | |
| 8233 TypeArgumentList get typeArguments => _typeArguments; | 7043 TypeArgumentList get typeArguments => _typeArguments; |
| 8234 | 7044 |
| 8235 /** | 7045 @override |
| 8236 * Set the type arguments to be applied to the method being invoked to the | |
| 8237 * given [typeArguments]. | |
| 8238 */ | |
| 8239 void set typeArguments(TypeArgumentList typeArguments) { | 7046 void set typeArguments(TypeArgumentList typeArguments) { |
| 8240 _typeArguments = _becomeParentOf(typeArguments); | 7047 _typeArguments = _becomeParentOf(typeArguments); |
| 8241 } | 7048 } |
| 8242 | 7049 |
| 8243 @override | 7050 @override |
| 8244 accept(AstVisitor visitor) => visitor.visitMethodInvocation(this); | 7051 accept(AstVisitor visitor) => visitor.visitMethodInvocation(this); |
| 8245 | 7052 |
| 8246 @override | 7053 @override |
| 8247 void visitChildren(AstVisitor visitor) { | 7054 void visitChildren(AstVisitor visitor) { |
| 8248 _safelyVisitChild(_target, visitor); | 7055 _safelyVisitChild(_target, visitor); |
| 8249 _safelyVisitChild(_methodName, visitor); | 7056 _safelyVisitChild(_methodName, visitor); |
| 8250 _safelyVisitChild(_typeArguments, visitor); | 7057 _safelyVisitChild(_typeArguments, visitor); |
| 8251 _safelyVisitChild(_argumentList, visitor); | 7058 _safelyVisitChild(_argumentList, visitor); |
| 8252 } | 7059 } |
| 8253 } | 7060 } |
| 8254 | 7061 |
| 8255 /** | 7062 /** |
| 8256 * A node that declares a single name within the scope of a compilation unit. | 7063 * A node that declares a single name within the scope of a compilation unit. |
| 8257 */ | 7064 */ |
| 8258 abstract class NamedCompilationUnitMember extends CompilationUnitMember { | 7065 abstract class NamedCompilationUnitMemberImpl extends CompilationUnitMemberImpl |
| 7066 implements NamedCompilationUnitMember { |
| 8259 /** | 7067 /** |
| 8260 * The name of the member being declared. | 7068 * The name of the member being declared. |
| 8261 */ | 7069 */ |
| 8262 SimpleIdentifier _name; | 7070 SimpleIdentifier _name; |
| 8263 | 7071 |
| 8264 /** | 7072 /** |
| 8265 * Initialize a newly created compilation unit member with the given [name]. | 7073 * Initialize a newly created compilation unit member with the given [name]. |
| 8266 * Either or both of the [comment] and [metadata] can be `null` if the member | 7074 * Either or both of the [comment] and [metadata] can be `null` if the member |
| 8267 * does not have the corresponding attribute. | 7075 * does not have the corresponding attribute. |
| 8268 */ | 7076 */ |
| 8269 NamedCompilationUnitMember( | 7077 NamedCompilationUnitMemberImpl( |
| 8270 Comment comment, List<Annotation> metadata, SimpleIdentifier name) | 7078 Comment comment, List<Annotation> metadata, SimpleIdentifier name) |
| 8271 : super(comment, metadata) { | 7079 : super(comment, metadata) { |
| 8272 _name = _becomeParentOf(name); | 7080 _name = _becomeParentOf(name); |
| 8273 } | 7081 } |
| 8274 | 7082 |
| 8275 /** | 7083 @override |
| 8276 * Return the name of the member being declared. | |
| 8277 */ | |
| 8278 SimpleIdentifier get name => _name; | 7084 SimpleIdentifier get name => _name; |
| 8279 | 7085 |
| 8280 /** | 7086 @override |
| 8281 * Set the name of the member being declared to the given [identifier]. | |
| 8282 */ | |
| 8283 void set name(SimpleIdentifier identifier) { | 7087 void set name(SimpleIdentifier identifier) { |
| 8284 _name = _becomeParentOf(identifier); | 7088 _name = _becomeParentOf(identifier); |
| 8285 } | 7089 } |
| 8286 } | 7090 } |
| 8287 | 7091 |
| 8288 /** | 7092 /** |
| 8289 * An expression that has a name associated with it. They are used in method | 7093 * An expression that has a name associated with it. They are used in method |
| 8290 * invocations when there are named parameters. | 7094 * invocations when there are named parameters. |
| 8291 * | 7095 * |
| 8292 * > namedExpression ::= | 7096 * > namedExpression ::= |
| 8293 * > [Label] [Expression] | 7097 * > [Label] [Expression] |
| 8294 */ | 7098 */ |
| 8295 class NamedExpression extends Expression { | 7099 class NamedExpressionImpl extends ExpressionImpl implements NamedExpression { |
| 8296 /** | 7100 /** |
| 8297 * The name associated with the expression. | 7101 * The name associated with the expression. |
| 8298 */ | 7102 */ |
| 8299 Label _name; | 7103 Label _name; |
| 8300 | 7104 |
| 8301 /** | 7105 /** |
| 8302 * The expression with which the name is associated. | 7106 * The expression with which the name is associated. |
| 8303 */ | 7107 */ |
| 8304 Expression _expression; | 7108 Expression _expression; |
| 8305 | 7109 |
| 8306 /** | 7110 /** |
| 8307 * Initialize a newly created named expression.. | 7111 * Initialize a newly created named expression.. |
| 8308 */ | 7112 */ |
| 8309 NamedExpression(Label name, Expression expression) { | 7113 NamedExpressionImpl(Label name, Expression expression) { |
| 8310 _name = _becomeParentOf(name); | 7114 _name = _becomeParentOf(name); |
| 8311 _expression = _becomeParentOf(expression); | 7115 _expression = _becomeParentOf(expression); |
| 8312 } | 7116 } |
| 8313 | 7117 |
| 8314 @override | 7118 @override |
| 8315 Token get beginToken => _name.beginToken; | 7119 Token get beginToken => _name.beginToken; |
| 8316 | 7120 |
| 8317 @override | 7121 @override |
| 8318 Iterable get childEntities => | 7122 Iterable get childEntities => |
| 8319 new ChildEntities()..add(_name)..add(_expression); | 7123 new ChildEntities()..add(_name)..add(_expression); |
| 8320 | 7124 |
| 8321 /** | 7125 @override |
| 8322 * Return the element representing the parameter being named by this | |
| 8323 * expression, or `null` if the AST structure has not been resolved or if | |
| 8324 * there is no parameter with the same name as this expression. | |
| 8325 */ | |
| 8326 ParameterElement get element { | 7126 ParameterElement get element { |
| 8327 Element element = _name.label.staticElement; | 7127 Element element = _name.label.staticElement; |
| 8328 if (element is ParameterElement) { | 7128 if (element is ParameterElement) { |
| 8329 return element; | 7129 return element; |
| 8330 } | 7130 } |
| 8331 return null; | 7131 return null; |
| 8332 } | 7132 } |
| 8333 | 7133 |
| 8334 @override | 7134 @override |
| 8335 Token get endToken => _expression.endToken; | 7135 Token get endToken => _expression.endToken; |
| 8336 | 7136 |
| 8337 /** | 7137 @override |
| 8338 * Return the expression with which the name is associated. | |
| 8339 */ | |
| 8340 Expression get expression => _expression; | 7138 Expression get expression => _expression; |
| 8341 | 7139 |
| 8342 /** | 7140 @override |
| 8343 * Set the expression with which the name is associated to the given | |
| 8344 * [expression]. | |
| 8345 */ | |
| 8346 void set expression(Expression expression) { | 7141 void set expression(Expression expression) { |
| 8347 _expression = _becomeParentOf(expression); | 7142 _expression = _becomeParentOf(expression); |
| 8348 } | 7143 } |
| 8349 | 7144 |
| 8350 /** | 7145 @override |
| 8351 * Return the name associated with the expression. | |
| 8352 */ | |
| 8353 Label get name => _name; | 7146 Label get name => _name; |
| 8354 | 7147 |
| 8355 /** | 7148 @override |
| 8356 * Set the name associated with the expression to the given [identifier]. | |
| 8357 */ | |
| 8358 void set name(Label identifier) { | 7149 void set name(Label identifier) { |
| 8359 _name = _becomeParentOf(identifier); | 7150 _name = _becomeParentOf(identifier); |
| 8360 } | 7151 } |
| 8361 | 7152 |
| 8362 @override | 7153 @override |
| 8363 int get precedence => 0; | 7154 int get precedence => 0; |
| 8364 | 7155 |
| 8365 @override | 7156 @override |
| 8366 accept(AstVisitor visitor) => visitor.visitNamedExpression(this); | 7157 accept(AstVisitor visitor) => visitor.visitNamedExpression(this); |
| 8367 | 7158 |
| 8368 @override | 7159 @override |
| 8369 void visitChildren(AstVisitor visitor) { | 7160 void visitChildren(AstVisitor visitor) { |
| 8370 _safelyVisitChild(_name, visitor); | 7161 _safelyVisitChild(_name, visitor); |
| 8371 _safelyVisitChild(_expression, visitor); | 7162 _safelyVisitChild(_expression, visitor); |
| 8372 } | 7163 } |
| 8373 } | 7164 } |
| 8374 | 7165 |
| 8375 /** | 7166 /** |
| 8376 * A node that represents a directive that impacts the namespace of a library. | 7167 * A node that represents a directive that impacts the namespace of a library. |
| 8377 * | 7168 * |
| 8378 * > directive ::= | 7169 * > directive ::= |
| 8379 * > [ExportDirective] | 7170 * > [ExportDirective] |
| 8380 * > | [ImportDirective] | 7171 * > | [ImportDirective] |
| 8381 */ | 7172 */ |
| 8382 abstract class NamespaceDirective extends UriBasedDirective { | 7173 abstract class NamespaceDirectiveImpl extends UriBasedDirectiveImpl |
| 7174 implements NamespaceDirective { |
| 8383 /** | 7175 /** |
| 8384 * The token representing the 'import' or 'export' keyword. | 7176 * The token representing the 'import' or 'export' keyword. |
| 8385 */ | 7177 */ |
| 8386 Token keyword; | 7178 Token keyword; |
| 8387 | 7179 |
| 8388 /** | 7180 /** |
| 8389 * The configurations used to control which library will actually be loaded at | 7181 * The configurations used to control which library will actually be loaded at |
| 8390 * run-time. | 7182 * run-time. |
| 8391 */ | 7183 */ |
| 8392 NodeList<Configuration> _configurations; | 7184 NodeList<Configuration> _configurations; |
| 8393 | 7185 |
| 8394 /** | 7186 /** |
| 8395 * The combinators used to control which names are imported or exported. | 7187 * The combinators used to control which names are imported or exported. |
| 8396 */ | 7188 */ |
| 8397 NodeList<Combinator> _combinators; | 7189 NodeList<Combinator> _combinators; |
| 8398 | 7190 |
| 8399 /** | 7191 /** |
| 8400 * The semicolon terminating the directive. | 7192 * The semicolon terminating the directive. |
| 8401 */ | 7193 */ |
| 8402 Token semicolon; | 7194 Token semicolon; |
| 8403 | 7195 |
| 8404 /** | 7196 /** |
| 8405 * Initialize a newly created namespace directive. Either or both of the | 7197 * Initialize a newly created namespace directive. Either or both of the |
| 8406 * [comment] and [metadata] can be `null` if the directive does not have the | 7198 * [comment] and [metadata] can be `null` if the directive does not have the |
| 8407 * corresponding attribute. The list of [combinators] can be `null` if there | 7199 * corresponding attribute. The list of [combinators] can be `null` if there |
| 8408 * are no combinators. | 7200 * are no combinators. |
| 8409 */ | 7201 */ |
| 8410 NamespaceDirective( | 7202 NamespaceDirectiveImpl( |
| 8411 Comment comment, | 7203 Comment comment, |
| 8412 List<Annotation> metadata, | 7204 List<Annotation> metadata, |
| 8413 this.keyword, | 7205 this.keyword, |
| 8414 StringLiteral libraryUri, | 7206 StringLiteral libraryUri, |
| 8415 List<Configuration> configurations, | 7207 List<Configuration> configurations, |
| 8416 List<Combinator> combinators, | 7208 List<Combinator> combinators, |
| 8417 this.semicolon) | 7209 this.semicolon) |
| 8418 : super(comment, metadata, libraryUri) { | 7210 : super(comment, metadata, libraryUri) { |
| 8419 _configurations = new NodeList<Configuration>(this, configurations); | 7211 _configurations = new NodeList<Configuration>(this, configurations); |
| 8420 _combinators = new NodeList<Combinator>(this, combinators); | 7212 _combinators = new NodeList<Combinator>(this, combinators); |
| 8421 } | 7213 } |
| 8422 | 7214 |
| 8423 /** | 7215 @override |
| 8424 * Return the combinators used to control how names are imported or exported. | |
| 8425 */ | |
| 8426 NodeList<Combinator> get combinators => _combinators; | 7216 NodeList<Combinator> get combinators => _combinators; |
| 8427 | 7217 |
| 8428 /** | 7218 @override |
| 8429 * Return the configurations used to control which library will actually be | |
| 8430 * loaded at run-time. | |
| 8431 */ | |
| 8432 NodeList<Configuration> get configurations => _configurations; | 7219 NodeList<Configuration> get configurations => _configurations; |
| 8433 | 7220 |
| 8434 @override | 7221 @override |
| 8435 Token get endToken => semicolon; | 7222 Token get endToken => semicolon; |
| 8436 | 7223 |
| 8437 @override | 7224 @override |
| 8438 Token get firstTokenAfterCommentAndMetadata => keyword; | 7225 Token get firstTokenAfterCommentAndMetadata => keyword; |
| 8439 | 7226 |
| 8440 @override | 7227 @override |
| 8441 LibraryElement get uriElement; | 7228 LibraryElement get uriElement; |
| 8442 } | 7229 } |
| 8443 | 7230 |
| 8444 /** | 7231 /** |
| 8445 * The "native" clause in an class declaration. | 7232 * The "native" clause in an class declaration. |
| 8446 * | 7233 * |
| 8447 * > nativeClause ::= | 7234 * > nativeClause ::= |
| 8448 * > 'native' [StringLiteral] | 7235 * > 'native' [StringLiteral] |
| 8449 */ | 7236 */ |
| 8450 class NativeClause extends AstNode { | 7237 class NativeClauseImpl extends AstNodeImpl implements NativeClause { |
| 8451 /** | 7238 /** |
| 8452 * The token representing the 'native' keyword. | 7239 * The token representing the 'native' keyword. |
| 8453 */ | 7240 */ |
| 8454 Token nativeKeyword; | 7241 Token nativeKeyword; |
| 8455 | 7242 |
| 8456 /** | 7243 /** |
| 8457 * The name of the native object that implements the class. | 7244 * The name of the native object that implements the class. |
| 8458 */ | 7245 */ |
| 8459 StringLiteral _name; | 7246 StringLiteral _name; |
| 8460 | 7247 |
| 8461 /** | 7248 /** |
| 8462 * Initialize a newly created native clause. | 7249 * Initialize a newly created native clause. |
| 8463 */ | 7250 */ |
| 8464 NativeClause(this.nativeKeyword, StringLiteral name) { | 7251 NativeClauseImpl(this.nativeKeyword, StringLiteral name) { |
| 8465 _name = _becomeParentOf(name); | 7252 _name = _becomeParentOf(name); |
| 8466 } | 7253 } |
| 8467 | 7254 |
| 8468 @override | 7255 @override |
| 8469 Token get beginToken => nativeKeyword; | 7256 Token get beginToken => nativeKeyword; |
| 8470 | 7257 |
| 8471 @override | 7258 @override |
| 8472 Iterable get childEntities => | 7259 Iterable get childEntities => |
| 8473 new ChildEntities()..add(nativeKeyword)..add(_name); | 7260 new ChildEntities()..add(nativeKeyword)..add(_name); |
| 8474 | 7261 |
| 8475 @override | 7262 @override |
| 8476 Token get endToken => _name.endToken; | 7263 Token get endToken => _name.endToken; |
| 8477 | 7264 |
| 8478 /** | 7265 @override |
| 8479 * Return the name of the native object that implements the class. | |
| 8480 */ | |
| 8481 StringLiteral get name => _name; | 7266 StringLiteral get name => _name; |
| 8482 | 7267 |
| 8483 /** | 7268 @override |
| 8484 * Set the name of the native object that implements the class to the given | |
| 8485 * [name]. | |
| 8486 */ | |
| 8487 void set name(StringLiteral name) { | 7269 void set name(StringLiteral name) { |
| 8488 _name = _becomeParentOf(name); | 7270 _name = _becomeParentOf(name); |
| 8489 } | 7271 } |
| 8490 | 7272 |
| 8491 @override | 7273 @override |
| 8492 accept(AstVisitor visitor) => visitor.visitNativeClause(this); | 7274 accept(AstVisitor visitor) => visitor.visitNativeClause(this); |
| 8493 | 7275 |
| 8494 @override | 7276 @override |
| 8495 void visitChildren(AstVisitor visitor) { | 7277 void visitChildren(AstVisitor visitor) { |
| 8496 _safelyVisitChild(_name, visitor); | 7278 _safelyVisitChild(_name, visitor); |
| 8497 } | 7279 } |
| 8498 } | 7280 } |
| 8499 | 7281 |
| 8500 /** | 7282 /** |
| 8501 * A function body that consists of a native keyword followed by a string | 7283 * A function body that consists of a native keyword followed by a string |
| 8502 * literal. | 7284 * literal. |
| 8503 * | 7285 * |
| 8504 * > nativeFunctionBody ::= | 7286 * > nativeFunctionBody ::= |
| 8505 * > 'native' [SimpleStringLiteral] ';' | 7287 * > 'native' [SimpleStringLiteral] ';' |
| 8506 */ | 7288 */ |
| 8507 class NativeFunctionBody extends FunctionBody { | 7289 class NativeFunctionBodyImpl extends FunctionBodyImpl |
| 7290 implements NativeFunctionBody { |
| 8508 /** | 7291 /** |
| 8509 * The token representing 'native' that marks the start of the function body. | 7292 * The token representing 'native' that marks the start of the function body. |
| 8510 */ | 7293 */ |
| 8511 Token nativeKeyword; | 7294 Token nativeKeyword; |
| 8512 | 7295 |
| 8513 /** | 7296 /** |
| 8514 * The string literal, after the 'native' token. | 7297 * The string literal, after the 'native' token. |
| 8515 */ | 7298 */ |
| 8516 StringLiteral _stringLiteral; | 7299 StringLiteral _stringLiteral; |
| 8517 | 7300 |
| 8518 /** | 7301 /** |
| 8519 * The token representing the semicolon that marks the end of the function | 7302 * The token representing the semicolon that marks the end of the function |
| 8520 * body. | 7303 * body. |
| 8521 */ | 7304 */ |
| 8522 Token semicolon; | 7305 Token semicolon; |
| 8523 | 7306 |
| 8524 /** | 7307 /** |
| 8525 * Initialize a newly created function body consisting of the 'native' token, | 7308 * Initialize a newly created function body consisting of the 'native' token, |
| 8526 * a string literal, and a semicolon. | 7309 * a string literal, and a semicolon. |
| 8527 */ | 7310 */ |
| 8528 NativeFunctionBody( | 7311 NativeFunctionBodyImpl( |
| 8529 this.nativeKeyword, StringLiteral stringLiteral, this.semicolon) { | 7312 this.nativeKeyword, StringLiteral stringLiteral, this.semicolon) { |
| 8530 _stringLiteral = _becomeParentOf(stringLiteral); | 7313 _stringLiteral = _becomeParentOf(stringLiteral); |
| 8531 } | 7314 } |
| 8532 | 7315 |
| 8533 @override | 7316 @override |
| 8534 Token get beginToken => nativeKeyword; | 7317 Token get beginToken => nativeKeyword; |
| 8535 | 7318 |
| 8536 @override | 7319 @override |
| 8537 Iterable get childEntities => new ChildEntities() | 7320 Iterable get childEntities => new ChildEntities() |
| 8538 ..add(nativeKeyword) | 7321 ..add(nativeKeyword) |
| 8539 ..add(_stringLiteral) | 7322 ..add(_stringLiteral) |
| 8540 ..add(semicolon); | 7323 ..add(semicolon); |
| 8541 | 7324 |
| 8542 @override | 7325 @override |
| 8543 Token get endToken => semicolon; | 7326 Token get endToken => semicolon; |
| 8544 | 7327 |
| 8545 /** | 7328 @override |
| 8546 * Return the string literal representing the string after the 'native' token. | |
| 8547 */ | |
| 8548 StringLiteral get stringLiteral => _stringLiteral; | 7329 StringLiteral get stringLiteral => _stringLiteral; |
| 8549 | 7330 |
| 8550 /** | 7331 @override |
| 8551 * Set the string literal representing the string after the 'native' token to | |
| 8552 * the given [stringLiteral]. | |
| 8553 */ | |
| 8554 void set stringLiteral(StringLiteral stringLiteral) { | 7332 void set stringLiteral(StringLiteral stringLiteral) { |
| 8555 _stringLiteral = _becomeParentOf(stringLiteral); | 7333 _stringLiteral = _becomeParentOf(stringLiteral); |
| 8556 } | 7334 } |
| 8557 | 7335 |
| 8558 @override | 7336 @override |
| 8559 accept(AstVisitor visitor) => visitor.visitNativeFunctionBody(this); | 7337 accept(AstVisitor visitor) => visitor.visitNativeFunctionBody(this); |
| 8560 | 7338 |
| 8561 @override | 7339 @override |
| 8562 void visitChildren(AstVisitor visitor) { | 7340 void visitChildren(AstVisitor visitor) { |
| 8563 _safelyVisitChild(_stringLiteral, visitor); | 7341 _safelyVisitChild(_stringLiteral, visitor); |
| 8564 } | 7342 } |
| 8565 } | 7343 } |
| 8566 | 7344 |
| 8567 /** | 7345 /** |
| 8568 * A list of AST nodes that have a common parent. | 7346 * A list of AST nodes that have a common parent. |
| 8569 */ | 7347 */ |
| 8570 class NodeList<E extends AstNode> extends Object with ListMixin<E> { | 7348 class NodeListImpl<E extends AstNode> extends Object |
| 7349 with ListMixin<E> |
| 7350 implements NodeList<E> { |
| 8571 /** | 7351 /** |
| 8572 * The node that is the parent of each of the elements in the list. | 7352 * The node that is the parent of each of the elements in the list. |
| 8573 */ | 7353 */ |
| 8574 AstNode owner; | 7354 AstNodeImpl owner; |
| 8575 | 7355 |
| 8576 /** | 7356 /** |
| 8577 * The elements contained in the list. | 7357 * The elements contained in the list. |
| 8578 */ | 7358 */ |
| 8579 List<E> _elements = <E>[]; | 7359 List<E> _elements = <E>[]; |
| 8580 | 7360 |
| 8581 /** | 7361 /** |
| 8582 * Initialize a newly created list of nodes such that all of the nodes that | 7362 * Initialize a newly created list of nodes such that all of the nodes that |
| 8583 * are added to the list will have their parent set to the given [owner]. The | 7363 * are added to the list will have their parent set to the given [owner]. The |
| 8584 * list will initially be populated with the given [elements]. | 7364 * list will initially be populated with the given [elements]. |
| 8585 */ | 7365 */ |
| 8586 NodeList(this.owner, [List<E> elements]) { | 7366 NodeListImpl(this.owner, [List<E> elements]) { |
| 8587 addAll(elements); | 7367 addAll(elements); |
| 8588 } | 7368 } |
| 8589 | 7369 |
| 8590 /** | 7370 @override |
| 8591 * Return the first token included in this node list's source range, or `null` | |
| 8592 * if the list is empty. | |
| 8593 */ | |
| 8594 Token get beginToken { | 7371 Token get beginToken { |
| 8595 if (_elements.length == 0) { | 7372 if (_elements.length == 0) { |
| 8596 return null; | 7373 return null; |
| 8597 } | 7374 } |
| 8598 return _elements[0].beginToken; | 7375 return _elements[0].beginToken; |
| 8599 } | 7376 } |
| 8600 | 7377 |
| 8601 /** | 7378 @override |
| 8602 * Return the last token included in this node list's source range, or `null` | |
| 8603 * if the list is empty. | |
| 8604 */ | |
| 8605 Token get endToken { | 7379 Token get endToken { |
| 8606 int length = _elements.length; | 7380 int length = _elements.length; |
| 8607 if (length == 0) { | 7381 if (length == 0) { |
| 8608 return null; | 7382 return null; |
| 8609 } | 7383 } |
| 8610 return _elements[length - 1].endToken; | 7384 return _elements[length - 1].endToken; |
| 8611 } | 7385 } |
| 8612 | 7386 |
| 8613 int get length => _elements.length; | 7387 int get length => _elements.length; |
| 8614 | 7388 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8626 } | 7400 } |
| 8627 | 7401 |
| 8628 void operator []=(int index, E node) { | 7402 void operator []=(int index, E node) { |
| 8629 if (index < 0 || index >= _elements.length) { | 7403 if (index < 0 || index >= _elements.length) { |
| 8630 throw new RangeError("Index: $index, Size: ${_elements.length}"); | 7404 throw new RangeError("Index: $index, Size: ${_elements.length}"); |
| 8631 } | 7405 } |
| 8632 owner._becomeParentOf(node); | 7406 owner._becomeParentOf(node); |
| 8633 _elements[index] = node; | 7407 _elements[index] = node; |
| 8634 } | 7408 } |
| 8635 | 7409 |
| 8636 /** | 7410 @override |
| 8637 * Use the given [visitor] to visit each of the nodes in this list. | |
| 8638 */ | |
| 8639 accept(AstVisitor visitor) { | 7411 accept(AstVisitor visitor) { |
| 8640 int length = _elements.length; | 7412 int length = _elements.length; |
| 8641 for (var i = 0; i < length; i++) { | 7413 for (var i = 0; i < length; i++) { |
| 8642 _elements[i].accept(visitor); | 7414 _elements[i].accept(visitor); |
| 8643 } | 7415 } |
| 8644 } | 7416 } |
| 8645 | 7417 |
| 8646 @override | 7418 @override |
| 8647 void add(E node) { | 7419 void add(E node) { |
| 8648 insert(length, node); | 7420 insert(length, node); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8691 } | 7463 } |
| 8692 | 7464 |
| 8693 /** | 7465 /** |
| 8694 * A formal parameter that is required (is not optional). | 7466 * A formal parameter that is required (is not optional). |
| 8695 * | 7467 * |
| 8696 * > normalFormalParameter ::= | 7468 * > normalFormalParameter ::= |
| 8697 * > [FunctionTypedFormalParameter] | 7469 * > [FunctionTypedFormalParameter] |
| 8698 * > | [FieldFormalParameter] | 7470 * > | [FieldFormalParameter] |
| 8699 * > | [SimpleFormalParameter] | 7471 * > | [SimpleFormalParameter] |
| 8700 */ | 7472 */ |
| 8701 abstract class NormalFormalParameter extends FormalParameter { | 7473 abstract class NormalFormalParameterImpl extends FormalParameterImpl |
| 7474 implements NormalFormalParameter { |
| 8702 /** | 7475 /** |
| 8703 * The documentation comment associated with this parameter, or `null` if this | 7476 * The documentation comment associated with this parameter, or `null` if this |
| 8704 * parameter does not have a documentation comment associated with it. | 7477 * parameter does not have a documentation comment associated with it. |
| 8705 */ | 7478 */ |
| 8706 Comment _comment; | 7479 Comment _comment; |
| 8707 | 7480 |
| 8708 /** | 7481 /** |
| 8709 * The annotations associated with this parameter. | 7482 * The annotations associated with this parameter. |
| 8710 */ | 7483 */ |
| 8711 NodeList<Annotation> _metadata; | 7484 NodeList<Annotation> _metadata; |
| 8712 | 7485 |
| 8713 /** | 7486 /** |
| 8714 * The name of the parameter being declared. | 7487 * The name of the parameter being declared. |
| 8715 */ | 7488 */ |
| 8716 SimpleIdentifier _identifier; | 7489 SimpleIdentifier _identifier; |
| 8717 | 7490 |
| 8718 /** | 7491 /** |
| 8719 * Initialize a newly created formal parameter. Either or both of the | 7492 * Initialize a newly created formal parameter. Either or both of the |
| 8720 * [comment] and [metadata] can be `null` if the parameter does not have the | 7493 * [comment] and [metadata] can be `null` if the parameter does not have the |
| 8721 * corresponding attribute. | 7494 * corresponding attribute. |
| 8722 */ | 7495 */ |
| 8723 NormalFormalParameter( | 7496 NormalFormalParameterImpl( |
| 8724 Comment comment, List<Annotation> metadata, SimpleIdentifier identifier) { | 7497 Comment comment, List<Annotation> metadata, SimpleIdentifier identifier) { |
| 8725 _comment = _becomeParentOf(comment); | 7498 _comment = _becomeParentOf(comment); |
| 8726 _metadata = new NodeList<Annotation>(this, metadata); | 7499 _metadata = new NodeList<Annotation>(this, metadata); |
| 8727 _identifier = _becomeParentOf(identifier); | 7500 _identifier = _becomeParentOf(identifier); |
| 8728 } | 7501 } |
| 8729 | 7502 |
| 8730 /** | 7503 @override |
| 8731 * Return the documentation comment associated with this parameter, or `null` | |
| 8732 * if this parameter does not have a documentation comment associated with it. | |
| 8733 */ | |
| 8734 Comment get documentationComment => _comment; | 7504 Comment get documentationComment => _comment; |
| 8735 | 7505 |
| 8736 /** | 7506 @override |
| 8737 * Set the documentation comment associated with this parameter to the given | |
| 8738 * [comment]. | |
| 8739 */ | |
| 8740 void set documentationComment(Comment comment) { | 7507 void set documentationComment(Comment comment) { |
| 8741 _comment = _becomeParentOf(comment); | 7508 _comment = _becomeParentOf(comment); |
| 8742 } | 7509 } |
| 8743 | 7510 |
| 8744 @override | 7511 @override |
| 8745 SimpleIdentifier get identifier => _identifier; | 7512 SimpleIdentifier get identifier => _identifier; |
| 8746 | 7513 |
| 8747 /** | 7514 @override |
| 8748 * Set the name of the parameter being declared to the given [identifier]. | |
| 8749 */ | |
| 8750 void set identifier(SimpleIdentifier identifier) { | 7515 void set identifier(SimpleIdentifier identifier) { |
| 8751 _identifier = _becomeParentOf(identifier); | 7516 _identifier = _becomeParentOf(identifier); |
| 8752 } | 7517 } |
| 8753 | 7518 |
| 8754 @override | 7519 @override |
| 8755 ParameterKind get kind { | 7520 ParameterKind get kind { |
| 8756 AstNode parent = this.parent; | 7521 AstNode parent = this.parent; |
| 8757 if (parent is DefaultFormalParameter) { | 7522 if (parent is DefaultFormalParameter) { |
| 8758 return parent.kind; | 7523 return parent.kind; |
| 8759 } | 7524 } |
| 8760 return ParameterKind.REQUIRED; | 7525 return ParameterKind.REQUIRED; |
| 8761 } | 7526 } |
| 8762 | 7527 |
| 8763 @override | 7528 @override |
| 8764 NodeList<Annotation> get metadata => _metadata; | 7529 NodeList<Annotation> get metadata => _metadata; |
| 8765 | 7530 |
| 8766 /** | 7531 @override |
| 8767 * Set the metadata associated with this node to the given [metadata]. | |
| 8768 */ | |
| 8769 void set metadata(List<Annotation> metadata) { | 7532 void set metadata(List<Annotation> metadata) { |
| 8770 _metadata.clear(); | 7533 _metadata.clear(); |
| 8771 _metadata.addAll(metadata); | 7534 _metadata.addAll(metadata); |
| 8772 } | 7535 } |
| 8773 | 7536 |
| 8774 /** | 7537 @override |
| 8775 * Return a list containing the comment and annotations associated with this | |
| 8776 * parameter, sorted in lexical order. | |
| 8777 */ | |
| 8778 List<AstNode> get sortedCommentAndAnnotations { | 7538 List<AstNode> get sortedCommentAndAnnotations { |
| 8779 return <AstNode>[] | 7539 return <AstNode>[] |
| 8780 ..add(_comment) | 7540 ..add(_comment) |
| 8781 ..addAll(_metadata) | 7541 ..addAll(_metadata) |
| 8782 ..sort(AstNode.LEXICAL_ORDER); | 7542 ..sort(AstNode.LEXICAL_ORDER); |
| 8783 } | 7543 } |
| 8784 | 7544 |
| 8785 ChildEntities get _childEntities { | 7545 ChildEntities get _childEntities { |
| 8786 ChildEntities result = new ChildEntities(); | 7546 ChildEntities result = new ChildEntities(); |
| 8787 if (_commentIsBeforeAnnotations()) { | 7547 if (_commentIsBeforeAnnotations()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8821 return _comment.offset < firstAnnotation.offset; | 7581 return _comment.offset < firstAnnotation.offset; |
| 8822 } | 7582 } |
| 8823 } | 7583 } |
| 8824 | 7584 |
| 8825 /** | 7585 /** |
| 8826 * A null literal expression. | 7586 * A null literal expression. |
| 8827 * | 7587 * |
| 8828 * > nullLiteral ::= | 7588 * > nullLiteral ::= |
| 8829 * > 'null' | 7589 * > 'null' |
| 8830 */ | 7590 */ |
| 8831 class NullLiteral extends Literal { | 7591 class NullLiteralImpl extends LiteralImpl implements NullLiteral { |
| 8832 /** | 7592 /** |
| 8833 * The token representing the literal. | 7593 * The token representing the literal. |
| 8834 */ | 7594 */ |
| 8835 Token literal; | 7595 Token literal; |
| 8836 | 7596 |
| 8837 /** | 7597 /** |
| 8838 * Initialize a newly created null literal. | 7598 * Initialize a newly created null literal. |
| 8839 */ | 7599 */ |
| 8840 NullLiteral(this.literal); | 7600 NullLiteralImpl(this.literal); |
| 8841 | 7601 |
| 8842 @override | 7602 @override |
| 8843 Token get beginToken => literal; | 7603 Token get beginToken => literal; |
| 8844 | 7604 |
| 8845 @override | 7605 @override |
| 8846 Iterable get childEntities => new ChildEntities()..add(literal); | 7606 Iterable get childEntities => new ChildEntities()..add(literal); |
| 8847 | 7607 |
| 8848 @override | 7608 @override |
| 8849 Token get endToken => literal; | 7609 Token get endToken => literal; |
| 8850 | 7610 |
| 8851 @override | 7611 @override |
| 8852 accept(AstVisitor visitor) => visitor.visitNullLiteral(this); | 7612 accept(AstVisitor visitor) => visitor.visitNullLiteral(this); |
| 8853 | 7613 |
| 8854 @override | 7614 @override |
| 8855 void visitChildren(AstVisitor visitor) { | 7615 void visitChildren(AstVisitor visitor) { |
| 8856 // There are no children to visit. | 7616 // There are no children to visit. |
| 8857 } | 7617 } |
| 8858 } | 7618 } |
| 8859 | 7619 |
| 8860 /** | 7620 /** |
| 8861 * A parenthesized expression. | 7621 * A parenthesized expression. |
| 8862 * | 7622 * |
| 8863 * > parenthesizedExpression ::= | 7623 * > parenthesizedExpression ::= |
| 8864 * > '(' [Expression] ')' | 7624 * > '(' [Expression] ')' |
| 8865 */ | 7625 */ |
| 8866 class ParenthesizedExpression extends Expression { | 7626 class ParenthesizedExpressionImpl extends ExpressionImpl |
| 7627 implements ParenthesizedExpression { |
| 8867 /** | 7628 /** |
| 8868 * The left parenthesis. | 7629 * The left parenthesis. |
| 8869 */ | 7630 */ |
| 8870 Token leftParenthesis; | 7631 Token leftParenthesis; |
| 8871 | 7632 |
| 8872 /** | 7633 /** |
| 8873 * The expression within the parentheses. | 7634 * The expression within the parentheses. |
| 8874 */ | 7635 */ |
| 8875 Expression _expression; | 7636 Expression _expression; |
| 8876 | 7637 |
| 8877 /** | 7638 /** |
| 8878 * The right parenthesis. | 7639 * The right parenthesis. |
| 8879 */ | 7640 */ |
| 8880 Token rightParenthesis; | 7641 Token rightParenthesis; |
| 8881 | 7642 |
| 8882 /** | 7643 /** |
| 8883 * Initialize a newly created parenthesized expression. | 7644 * Initialize a newly created parenthesized expression. |
| 8884 */ | 7645 */ |
| 8885 ParenthesizedExpression( | 7646 ParenthesizedExpressionImpl( |
| 8886 this.leftParenthesis, Expression expression, this.rightParenthesis) { | 7647 this.leftParenthesis, Expression expression, this.rightParenthesis) { |
| 8887 _expression = _becomeParentOf(expression); | 7648 _expression = _becomeParentOf(expression); |
| 8888 } | 7649 } |
| 8889 | 7650 |
| 8890 @override | 7651 @override |
| 8891 Token get beginToken => leftParenthesis; | 7652 Token get beginToken => leftParenthesis; |
| 8892 | 7653 |
| 8893 @override | 7654 @override |
| 8894 Iterable get childEntities => new ChildEntities() | 7655 Iterable get childEntities => new ChildEntities() |
| 8895 ..add(leftParenthesis) | 7656 ..add(leftParenthesis) |
| 8896 ..add(_expression) | 7657 ..add(_expression) |
| 8897 ..add(rightParenthesis); | 7658 ..add(rightParenthesis); |
| 8898 | 7659 |
| 8899 @override | 7660 @override |
| 8900 Token get endToken => rightParenthesis; | 7661 Token get endToken => rightParenthesis; |
| 8901 | 7662 |
| 8902 /** | 7663 @override |
| 8903 * Return the expression within the parentheses. | |
| 8904 */ | |
| 8905 Expression get expression => _expression; | 7664 Expression get expression => _expression; |
| 8906 | 7665 |
| 8907 /** | 7666 @override |
| 8908 * Set the expression within the parentheses to the given [expression]. | |
| 8909 */ | |
| 8910 void set expression(Expression expression) { | 7667 void set expression(Expression expression) { |
| 8911 _expression = _becomeParentOf(expression); | 7668 _expression = _becomeParentOf(expression); |
| 8912 } | 7669 } |
| 8913 | 7670 |
| 8914 @override | 7671 @override |
| 8915 int get precedence => 15; | 7672 int get precedence => 15; |
| 8916 | 7673 |
| 8917 @override | 7674 @override |
| 8918 accept(AstVisitor visitor) => visitor.visitParenthesizedExpression(this); | 7675 accept(AstVisitor visitor) => visitor.visitParenthesizedExpression(this); |
| 8919 | 7676 |
| 8920 @override | 7677 @override |
| 8921 void visitChildren(AstVisitor visitor) { | 7678 void visitChildren(AstVisitor visitor) { |
| 8922 _safelyVisitChild(_expression, visitor); | 7679 _safelyVisitChild(_expression, visitor); |
| 8923 } | 7680 } |
| 8924 } | 7681 } |
| 8925 | 7682 |
| 8926 /** | 7683 /** |
| 8927 * A part directive. | 7684 * A part directive. |
| 8928 * | 7685 * |
| 8929 * > partDirective ::= | 7686 * > partDirective ::= |
| 8930 * > [Annotation] 'part' [StringLiteral] ';' | 7687 * > [Annotation] 'part' [StringLiteral] ';' |
| 8931 */ | 7688 */ |
| 8932 class PartDirective extends UriBasedDirective { | 7689 class PartDirectiveImpl extends UriBasedDirectiveImpl implements PartDirective { |
| 8933 /** | 7690 /** |
| 8934 * The token representing the 'part' keyword. | 7691 * The token representing the 'part' keyword. |
| 8935 */ | 7692 */ |
| 8936 Token partKeyword; | 7693 Token partKeyword; |
| 8937 | 7694 |
| 8938 /** | 7695 /** |
| 8939 * The semicolon terminating the directive. | 7696 * The semicolon terminating the directive. |
| 8940 */ | 7697 */ |
| 8941 Token semicolon; | 7698 Token semicolon; |
| 8942 | 7699 |
| 8943 /** | 7700 /** |
| 8944 * Initialize a newly created part directive. Either or both of the [comment] | 7701 * Initialize a newly created part directive. Either or both of the [comment] |
| 8945 * and [metadata] can be `null` if the directive does not have the | 7702 * and [metadata] can be `null` if the directive does not have the |
| 8946 * corresponding attribute. | 7703 * corresponding attribute. |
| 8947 */ | 7704 */ |
| 8948 PartDirective(Comment comment, List<Annotation> metadata, this.partKeyword, | 7705 PartDirectiveImpl(Comment comment, List<Annotation> metadata, |
| 8949 StringLiteral partUri, this.semicolon) | 7706 this.partKeyword, StringLiteral partUri, this.semicolon) |
| 8950 : super(comment, metadata, partUri); | 7707 : super(comment, metadata, partUri); |
| 8951 | 7708 |
| 8952 @override | 7709 @override |
| 8953 Iterable get childEntities => | 7710 Iterable get childEntities => |
| 8954 super._childEntities..add(partKeyword)..add(_uri)..add(semicolon); | 7711 super._childEntities..add(partKeyword)..add(_uri)..add(semicolon); |
| 8955 | 7712 |
| 8956 @override | 7713 @override |
| 8957 Token get endToken => semicolon; | 7714 Token get endToken => semicolon; |
| 8958 | 7715 |
| 8959 @override | 7716 @override |
| 8960 Token get firstTokenAfterCommentAndMetadata => partKeyword; | 7717 Token get firstTokenAfterCommentAndMetadata => partKeyword; |
| 8961 | 7718 |
| 8962 @override | 7719 @override |
| 8963 Token get keyword => partKeyword; | 7720 Token get keyword => partKeyword; |
| 8964 | 7721 |
| 8965 @override | 7722 @override |
| 8966 CompilationUnitElement get uriElement => element as CompilationUnitElement; | 7723 CompilationUnitElement get uriElement => element as CompilationUnitElement; |
| 8967 | 7724 |
| 8968 @override | 7725 @override |
| 8969 accept(AstVisitor visitor) => visitor.visitPartDirective(this); | 7726 accept(AstVisitor visitor) => visitor.visitPartDirective(this); |
| 8970 } | 7727 } |
| 8971 | 7728 |
| 8972 /** | 7729 /** |
| 8973 * A part-of directive. | 7730 * A part-of directive. |
| 8974 * | 7731 * |
| 8975 * > partOfDirective ::= | 7732 * > partOfDirective ::= |
| 8976 * > [Annotation] 'part' 'of' [Identifier] ';' | 7733 * > [Annotation] 'part' 'of' [Identifier] ';' |
| 8977 */ | 7734 */ |
| 8978 class PartOfDirective extends Directive { | 7735 class PartOfDirectiveImpl extends DirectiveImpl implements PartOfDirective { |
| 8979 /** | 7736 /** |
| 8980 * The token representing the 'part' keyword. | 7737 * The token representing the 'part' keyword. |
| 8981 */ | 7738 */ |
| 8982 Token partKeyword; | 7739 Token partKeyword; |
| 8983 | 7740 |
| 8984 /** | 7741 /** |
| 8985 * The token representing the 'of' keyword. | 7742 * The token representing the 'of' keyword. |
| 8986 */ | 7743 */ |
| 8987 Token ofKeyword; | 7744 Token ofKeyword; |
| 8988 | 7745 |
| 8989 /** | 7746 /** |
| 8990 * The name of the library that the containing compilation unit is part of. | 7747 * The name of the library that the containing compilation unit is part of. |
| 8991 */ | 7748 */ |
| 8992 LibraryIdentifier _libraryName; | 7749 LibraryIdentifier _libraryName; |
| 8993 | 7750 |
| 8994 /** | 7751 /** |
| 8995 * The semicolon terminating the directive. | 7752 * The semicolon terminating the directive. |
| 8996 */ | 7753 */ |
| 8997 Token semicolon; | 7754 Token semicolon; |
| 8998 | 7755 |
| 8999 /** | 7756 /** |
| 9000 * Initialize a newly created part-of directive. Either or both of the | 7757 * Initialize a newly created part-of directive. Either or both of the |
| 9001 * [comment] and [metadata] can be `null` if the directive does not have the | 7758 * [comment] and [metadata] can be `null` if the directive does not have the |
| 9002 * corresponding attribute. | 7759 * corresponding attribute. |
| 9003 */ | 7760 */ |
| 9004 PartOfDirective(Comment comment, List<Annotation> metadata, this.partKeyword, | 7761 PartOfDirectiveImpl( |
| 9005 this.ofKeyword, LibraryIdentifier libraryName, this.semicolon) | 7762 Comment comment, |
| 7763 List<Annotation> metadata, |
| 7764 this.partKeyword, |
| 7765 this.ofKeyword, |
| 7766 LibraryIdentifier libraryName, |
| 7767 this.semicolon) |
| 9006 : super(comment, metadata) { | 7768 : super(comment, metadata) { |
| 9007 _libraryName = _becomeParentOf(libraryName); | 7769 _libraryName = _becomeParentOf(libraryName); |
| 9008 } | 7770 } |
| 9009 | 7771 |
| 9010 @override | 7772 @override |
| 9011 Iterable get childEntities => super._childEntities | 7773 Iterable get childEntities => super._childEntities |
| 9012 ..add(partKeyword) | 7774 ..add(partKeyword) |
| 9013 ..add(ofKeyword) | 7775 ..add(ofKeyword) |
| 9014 ..add(_libraryName) | 7776 ..add(_libraryName) |
| 9015 ..add(semicolon); | 7777 ..add(semicolon); |
| 9016 | 7778 |
| 9017 @override | 7779 @override |
| 9018 Token get endToken => semicolon; | 7780 Token get endToken => semicolon; |
| 9019 | 7781 |
| 9020 @override | 7782 @override |
| 9021 Token get firstTokenAfterCommentAndMetadata => partKeyword; | 7783 Token get firstTokenAfterCommentAndMetadata => partKeyword; |
| 9022 | 7784 |
| 9023 @override | 7785 @override |
| 9024 Token get keyword => partKeyword; | 7786 Token get keyword => partKeyword; |
| 9025 | 7787 |
| 9026 /** | 7788 @override |
| 9027 * Return the name of the library that the containing compilation unit is part | |
| 9028 * of. | |
| 9029 */ | |
| 9030 LibraryIdentifier get libraryName => _libraryName; | 7789 LibraryIdentifier get libraryName => _libraryName; |
| 9031 | 7790 |
| 9032 /** | 7791 @override |
| 9033 * Set the name of the library that the containing compilation unit is part of | |
| 9034 * to the given [libraryName]. | |
| 9035 */ | |
| 9036 void set libraryName(LibraryIdentifier libraryName) { | 7792 void set libraryName(LibraryIdentifier libraryName) { |
| 9037 _libraryName = _becomeParentOf(libraryName); | 7793 _libraryName = _becomeParentOf(libraryName); |
| 9038 } | 7794 } |
| 9039 | 7795 |
| 9040 @override | 7796 @override |
| 9041 accept(AstVisitor visitor) => visitor.visitPartOfDirective(this); | 7797 accept(AstVisitor visitor) => visitor.visitPartOfDirective(this); |
| 9042 | 7798 |
| 9043 @override | 7799 @override |
| 9044 void visitChildren(AstVisitor visitor) { | 7800 void visitChildren(AstVisitor visitor) { |
| 9045 super.visitChildren(visitor); | 7801 super.visitChildren(visitor); |
| 9046 _safelyVisitChild(_libraryName, visitor); | 7802 _safelyVisitChild(_libraryName, visitor); |
| 9047 } | 7803 } |
| 9048 } | 7804 } |
| 9049 | 7805 |
| 9050 /** | 7806 /** |
| 9051 * A postfix unary expression. | 7807 * A postfix unary expression. |
| 9052 * | 7808 * |
| 9053 * > postfixExpression ::= | 7809 * > postfixExpression ::= |
| 9054 * > [Expression] [Token] | 7810 * > [Expression] [Token] |
| 9055 */ | 7811 */ |
| 9056 class PostfixExpression extends Expression { | 7812 class PostfixExpressionImpl extends ExpressionImpl |
| 7813 implements PostfixExpression { |
| 9057 /** | 7814 /** |
| 9058 * The expression computing the operand for the operator. | 7815 * The expression computing the operand for the operator. |
| 9059 */ | 7816 */ |
| 9060 Expression _operand; | 7817 Expression _operand; |
| 9061 | 7818 |
| 9062 /** | 7819 /** |
| 9063 * The postfix operator being applied to the operand. | 7820 * The postfix operator being applied to the operand. |
| 9064 */ | 7821 */ |
| 9065 Token operator; | 7822 Token operator; |
| 9066 | 7823 |
| 9067 /** | 7824 /** |
| 9068 * The element associated with this the operator based on the propagated type | 7825 * The element associated with this the operator based on the propagated type |
| 9069 * of the operand, or `null` if the AST structure has not been resolved, if | 7826 * of the operand, or `null` if the AST structure has not been resolved, if |
| 9070 * the operator is not user definable, or if the operator could not be | 7827 * the operator is not user definable, or if the operator could not be |
| 9071 * resolved. | 7828 * resolved. |
| 9072 */ | 7829 */ |
| 9073 MethodElement propagatedElement; | 7830 MethodElement propagatedElement; |
| 9074 | 7831 |
| 9075 /** | 7832 /** |
| 9076 * The element associated with the operator based on the static type of the | 7833 * The element associated with the operator based on the static type of the |
| 9077 * operand, or `null` if the AST structure has not been resolved, if the | 7834 * operand, or `null` if the AST structure has not been resolved, if the |
| 9078 * operator is not user definable, or if the operator could not be resolved. | 7835 * operator is not user definable, or if the operator could not be resolved. |
| 9079 */ | 7836 */ |
| 9080 MethodElement staticElement; | 7837 MethodElement staticElement; |
| 9081 | 7838 |
| 9082 /** | 7839 /** |
| 9083 * Initialize a newly created postfix expression. | 7840 * Initialize a newly created postfix expression. |
| 9084 */ | 7841 */ |
| 9085 PostfixExpression(Expression operand, this.operator) { | 7842 PostfixExpressionImpl(Expression operand, this.operator) { |
| 9086 _operand = _becomeParentOf(operand); | 7843 _operand = _becomeParentOf(operand); |
| 9087 } | 7844 } |
| 9088 | 7845 |
| 9089 @override | 7846 @override |
| 9090 Token get beginToken => _operand.beginToken; | 7847 Token get beginToken => _operand.beginToken; |
| 9091 | 7848 |
| 9092 /** | 7849 @override |
| 9093 * Return the best element available for this operator. If resolution was able | |
| 9094 * to find a better element based on type propagation, that element will be | |
| 9095 * returned. Otherwise, the element found using the result of static analysis | |
| 9096 * will be returned. If resolution has not been performed, then `null` will be | |
| 9097 * returned. | |
| 9098 */ | |
| 9099 MethodElement get bestElement { | 7850 MethodElement get bestElement { |
| 9100 MethodElement element = propagatedElement; | 7851 MethodElement element = propagatedElement; |
| 9101 if (element == null) { | 7852 if (element == null) { |
| 9102 element = staticElement; | 7853 element = staticElement; |
| 9103 } | 7854 } |
| 9104 return element; | 7855 return element; |
| 9105 } | 7856 } |
| 9106 | 7857 |
| 9107 @override | 7858 @override |
| 9108 Iterable get childEntities => | 7859 Iterable get childEntities => |
| 9109 new ChildEntities()..add(_operand)..add(operator); | 7860 new ChildEntities()..add(_operand)..add(operator); |
| 9110 | 7861 |
| 9111 @override | 7862 @override |
| 9112 Token get endToken => operator; | 7863 Token get endToken => operator; |
| 9113 | 7864 |
| 9114 /** | 7865 @override |
| 9115 * Return the expression computing the operand for the operator. | |
| 9116 */ | |
| 9117 Expression get operand => _operand; | 7866 Expression get operand => _operand; |
| 9118 | 7867 |
| 9119 /** | 7868 @override |
| 9120 * Set the expression computing the operand for the operator to the given | |
| 9121 * [expression]. | |
| 9122 */ | |
| 9123 void set operand(Expression expression) { | 7869 void set operand(Expression expression) { |
| 9124 _operand = _becomeParentOf(expression); | 7870 _operand = _becomeParentOf(expression); |
| 9125 } | 7871 } |
| 9126 | 7872 |
| 9127 @override | 7873 @override |
| 9128 int get precedence => 15; | 7874 int get precedence => 15; |
| 9129 | 7875 |
| 9130 /** | 7876 /** |
| 9131 * If the AST structure has been resolved, and the function being invoked is | 7877 * If the AST structure has been resolved, and the function being invoked is |
| 9132 * known based on propagated type information, then return the parameter | 7878 * known based on propagated type information, then return the parameter |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9170 } | 7916 } |
| 9171 } | 7917 } |
| 9172 | 7918 |
| 9173 /** | 7919 /** |
| 9174 * An identifier that is prefixed or an access to an object property where the | 7920 * An identifier that is prefixed or an access to an object property where the |
| 9175 * target of the property access is a simple identifier. | 7921 * target of the property access is a simple identifier. |
| 9176 * | 7922 * |
| 9177 * > prefixedIdentifier ::= | 7923 * > prefixedIdentifier ::= |
| 9178 * > [SimpleIdentifier] '.' [SimpleIdentifier] | 7924 * > [SimpleIdentifier] '.' [SimpleIdentifier] |
| 9179 */ | 7925 */ |
| 9180 class PrefixedIdentifier extends Identifier { | 7926 class PrefixedIdentifierImpl extends IdentifierImpl |
| 7927 implements PrefixedIdentifier { |
| 9181 /** | 7928 /** |
| 9182 * The prefix associated with the library in which the identifier is defined. | 7929 * The prefix associated with the library in which the identifier is defined. |
| 9183 */ | 7930 */ |
| 9184 SimpleIdentifier _prefix; | 7931 SimpleIdentifier _prefix; |
| 9185 | 7932 |
| 9186 /** | 7933 /** |
| 9187 * The period used to separate the prefix from the identifier. | 7934 * The period used to separate the prefix from the identifier. |
| 9188 */ | 7935 */ |
| 9189 Token period; | 7936 Token period; |
| 9190 | 7937 |
| 9191 /** | 7938 /** |
| 9192 * The identifier being prefixed. | 7939 * The identifier being prefixed. |
| 9193 */ | 7940 */ |
| 9194 SimpleIdentifier _identifier; | 7941 SimpleIdentifier _identifier; |
| 9195 | 7942 |
| 9196 /** | 7943 /** |
| 9197 * Initialize a newly created prefixed identifier. | 7944 * Initialize a newly created prefixed identifier. |
| 9198 */ | 7945 */ |
| 9199 PrefixedIdentifier( | 7946 PrefixedIdentifierImpl( |
| 9200 SimpleIdentifier prefix, this.period, SimpleIdentifier identifier) { | 7947 SimpleIdentifier prefix, this.period, SimpleIdentifier identifier) { |
| 9201 _prefix = _becomeParentOf(prefix); | 7948 _prefix = _becomeParentOf(prefix); |
| 9202 _identifier = _becomeParentOf(identifier); | 7949 _identifier = _becomeParentOf(identifier); |
| 9203 } | 7950 } |
| 9204 | 7951 |
| 9205 @override | 7952 @override |
| 9206 Token get beginToken => _prefix.beginToken; | 7953 Token get beginToken => _prefix.beginToken; |
| 9207 | 7954 |
| 9208 @override | 7955 @override |
| 9209 Element get bestElement { | 7956 Element get bestElement { |
| 9210 if (_identifier == null) { | 7957 if (_identifier == null) { |
| 9211 return null; | 7958 return null; |
| 9212 } | 7959 } |
| 9213 return _identifier.bestElement; | 7960 return _identifier.bestElement; |
| 9214 } | 7961 } |
| 9215 | 7962 |
| 9216 @override | 7963 @override |
| 9217 Iterable get childEntities => | 7964 Iterable get childEntities => |
| 9218 new ChildEntities()..add(_prefix)..add(period)..add(_identifier); | 7965 new ChildEntities()..add(_prefix)..add(period)..add(_identifier); |
| 9219 | 7966 |
| 9220 @override | 7967 @override |
| 9221 Token get endToken => _identifier.endToken; | 7968 Token get endToken => _identifier.endToken; |
| 9222 | 7969 |
| 9223 /** | 7970 @override |
| 9224 * Return the identifier being prefixed. | |
| 9225 */ | |
| 9226 SimpleIdentifier get identifier => _identifier; | 7971 SimpleIdentifier get identifier => _identifier; |
| 9227 | 7972 |
| 9228 /** | 7973 @override |
| 9229 * Set the identifier being prefixed to the given [identifier]. | |
| 9230 */ | |
| 9231 void set identifier(SimpleIdentifier identifier) { | 7974 void set identifier(SimpleIdentifier identifier) { |
| 9232 _identifier = _becomeParentOf(identifier); | 7975 _identifier = _becomeParentOf(identifier); |
| 9233 } | 7976 } |
| 9234 | 7977 |
| 9235 /** | 7978 @override |
| 9236 * Return `true` if this type is a deferred type. If the AST structure has not | |
| 9237 * been resolved, then return `false`. | |
| 9238 * | |
| 9239 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form | |
| 9240 * </i>p.T</i> where <i>p</i> is a deferred prefix. | |
| 9241 */ | |
| 9242 bool get isDeferred { | 7979 bool get isDeferred { |
| 9243 Element element = _prefix.staticElement; | 7980 Element element = _prefix.staticElement; |
| 9244 if (element is! PrefixElement) { | 7981 if (element is! PrefixElement) { |
| 9245 return false; | 7982 return false; |
| 9246 } | 7983 } |
| 9247 PrefixElement prefixElement = element as PrefixElement; | 7984 PrefixElement prefixElement = element as PrefixElement; |
| 9248 List<ImportElement> imports = | 7985 List<ImportElement> imports = |
| 9249 prefixElement.enclosingElement.getImportsWithPrefix(prefixElement); | 7986 prefixElement.enclosingElement.getImportsWithPrefix(prefixElement); |
| 9250 if (imports.length != 1) { | 7987 if (imports.length != 1) { |
| 9251 return false; | 7988 return false; |
| 9252 } | 7989 } |
| 9253 return imports[0].isDeferred; | 7990 return imports[0].isDeferred; |
| 9254 } | 7991 } |
| 9255 | 7992 |
| 9256 @override | 7993 @override |
| 9257 String get name => "${_prefix.name}.${_identifier.name}"; | 7994 String get name => "${_prefix.name}.${_identifier.name}"; |
| 9258 | 7995 |
| 9259 @override | 7996 @override |
| 9260 int get precedence => 15; | 7997 int get precedence => 15; |
| 9261 | 7998 |
| 9262 /** | 7999 @override |
| 9263 * Return the prefix associated with the library in which the identifier is | |
| 9264 * defined. | |
| 9265 */ | |
| 9266 SimpleIdentifier get prefix => _prefix; | 8000 SimpleIdentifier get prefix => _prefix; |
| 9267 | 8001 |
| 9268 /** | 8002 @override |
| 9269 * Set the prefix associated with the library in which the identifier is | |
| 9270 * defined to the given [identifier]. | |
| 9271 */ | |
| 9272 void set prefix(SimpleIdentifier identifier) { | 8003 void set prefix(SimpleIdentifier identifier) { |
| 9273 _prefix = _becomeParentOf(identifier); | 8004 _prefix = _becomeParentOf(identifier); |
| 9274 } | 8005 } |
| 9275 | 8006 |
| 9276 @override | 8007 @override |
| 9277 Element get propagatedElement { | 8008 Element get propagatedElement { |
| 9278 if (_identifier == null) { | 8009 if (_identifier == null) { |
| 9279 return null; | 8010 return null; |
| 9280 } | 8011 } |
| 9281 return _identifier.propagatedElement; | 8012 return _identifier.propagatedElement; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 9298 _safelyVisitChild(_identifier, visitor); | 8029 _safelyVisitChild(_identifier, visitor); |
| 9299 } | 8030 } |
| 9300 } | 8031 } |
| 9301 | 8032 |
| 9302 /** | 8033 /** |
| 9303 * A prefix unary expression. | 8034 * A prefix unary expression. |
| 9304 * | 8035 * |
| 9305 * > prefixExpression ::= | 8036 * > prefixExpression ::= |
| 9306 * > [Token] [Expression] | 8037 * > [Token] [Expression] |
| 9307 */ | 8038 */ |
| 9308 class PrefixExpression extends Expression { | 8039 class PrefixExpressionImpl extends ExpressionImpl implements PrefixExpression { |
| 9309 /** | 8040 /** |
| 9310 * The prefix operator being applied to the operand. | 8041 * The prefix operator being applied to the operand. |
| 9311 */ | 8042 */ |
| 9312 Token operator; | 8043 Token operator; |
| 9313 | 8044 |
| 9314 /** | 8045 /** |
| 9315 * The expression computing the operand for the operator. | 8046 * The expression computing the operand for the operator. |
| 9316 */ | 8047 */ |
| 9317 Expression _operand; | 8048 Expression _operand; |
| 9318 | 8049 |
| 9319 /** | 8050 /** |
| 9320 * The element associated with the operator based on the static type of the | 8051 * The element associated with the operator based on the static type of the |
| 9321 * operand, or `null` if the AST structure has not been resolved, if the | 8052 * operand, or `null` if the AST structure has not been resolved, if the |
| 9322 * operator is not user definable, or if the operator could not be resolved. | 8053 * operator is not user definable, or if the operator could not be resolved. |
| 9323 */ | 8054 */ |
| 9324 MethodElement staticElement; | 8055 MethodElement staticElement; |
| 9325 | 8056 |
| 9326 /** | 8057 /** |
| 9327 * The element associated with the operator based on the propagated type of | 8058 * The element associated with the operator based on the propagated type of |
| 9328 * the operand, or `null` if the AST structure has not been resolved, if the | 8059 * the operand, or `null` if the AST structure has not been resolved, if the |
| 9329 * operator is not user definable, or if the operator could not be resolved. | 8060 * operator is not user definable, or if the operator could not be resolved. |
| 9330 */ | 8061 */ |
| 9331 MethodElement propagatedElement; | 8062 MethodElement propagatedElement; |
| 9332 | 8063 |
| 9333 /** | 8064 /** |
| 9334 * Initialize a newly created prefix expression. | 8065 * Initialize a newly created prefix expression. |
| 9335 */ | 8066 */ |
| 9336 PrefixExpression(this.operator, Expression operand) { | 8067 PrefixExpressionImpl(this.operator, Expression operand) { |
| 9337 _operand = _becomeParentOf(operand); | 8068 _operand = _becomeParentOf(operand); |
| 9338 } | 8069 } |
| 9339 | 8070 |
| 9340 @override | 8071 @override |
| 9341 Token get beginToken => operator; | 8072 Token get beginToken => operator; |
| 9342 | 8073 |
| 9343 /** | 8074 @override |
| 9344 * Return the best element available for this operator. If resolution was able | |
| 9345 * to find a better element based on type propagation, that element will be | |
| 9346 * returned. Otherwise, the element found using the result of static analysis | |
| 9347 * will be returned. If resolution has not been performed, then `null` will be | |
| 9348 * returned. | |
| 9349 */ | |
| 9350 MethodElement get bestElement { | 8075 MethodElement get bestElement { |
| 9351 MethodElement element = propagatedElement; | 8076 MethodElement element = propagatedElement; |
| 9352 if (element == null) { | 8077 if (element == null) { |
| 9353 element = staticElement; | 8078 element = staticElement; |
| 9354 } | 8079 } |
| 9355 return element; | 8080 return element; |
| 9356 } | 8081 } |
| 9357 | 8082 |
| 9358 @override | 8083 @override |
| 9359 Iterable get childEntities => | 8084 Iterable get childEntities => |
| 9360 new ChildEntities()..add(operator)..add(_operand); | 8085 new ChildEntities()..add(operator)..add(_operand); |
| 9361 | 8086 |
| 9362 @override | 8087 @override |
| 9363 Token get endToken => _operand.endToken; | 8088 Token get endToken => _operand.endToken; |
| 9364 | 8089 |
| 9365 /** | 8090 @override |
| 9366 * Return the expression computing the operand for the operator. | |
| 9367 */ | |
| 9368 Expression get operand => _operand; | 8091 Expression get operand => _operand; |
| 9369 | 8092 |
| 9370 /** | 8093 @override |
| 9371 * Set the expression computing the operand for the operator to the given | |
| 9372 * [expression]. | |
| 9373 */ | |
| 9374 void set operand(Expression expression) { | 8094 void set operand(Expression expression) { |
| 9375 _operand = _becomeParentOf(expression); | 8095 _operand = _becomeParentOf(expression); |
| 9376 } | 8096 } |
| 9377 | 8097 |
| 9378 @override | 8098 @override |
| 9379 int get precedence => 14; | 8099 int get precedence => 14; |
| 9380 | 8100 |
| 9381 /** | 8101 /** |
| 9382 * If the AST structure has been resolved, and the function being invoked is | 8102 * If the AST structure has been resolved, and the function being invoked is |
| 9383 * known based on propagated type information, then return the parameter | 8103 * known based on propagated type information, then return the parameter |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9424 /** | 8144 /** |
| 9425 * The access of a property of an object. | 8145 * The access of a property of an object. |
| 9426 * | 8146 * |
| 9427 * Note, however, that accesses to properties of objects can also be represented | 8147 * Note, however, that accesses to properties of objects can also be represented |
| 9428 * as [PrefixedIdentifier] nodes in cases where the target is also a simple | 8148 * as [PrefixedIdentifier] nodes in cases where the target is also a simple |
| 9429 * identifier. | 8149 * identifier. |
| 9430 * | 8150 * |
| 9431 * > propertyAccess ::= | 8151 * > propertyAccess ::= |
| 9432 * > [Expression] '.' [SimpleIdentifier] | 8152 * > [Expression] '.' [SimpleIdentifier] |
| 9433 */ | 8153 */ |
| 9434 class PropertyAccess extends Expression { | 8154 class PropertyAccessImpl extends ExpressionImpl implements PropertyAccess { |
| 9435 /** | 8155 /** |
| 9436 * The expression computing the object defining the property being accessed. | 8156 * The expression computing the object defining the property being accessed. |
| 9437 */ | 8157 */ |
| 9438 Expression _target; | 8158 Expression _target; |
| 9439 | 8159 |
| 9440 /** | 8160 /** |
| 9441 * The property access operator. | 8161 * The property access operator. |
| 9442 */ | 8162 */ |
| 9443 Token operator; | 8163 Token operator; |
| 9444 | 8164 |
| 9445 /** | 8165 /** |
| 9446 * The name of the property being accessed. | 8166 * The name of the property being accessed. |
| 9447 */ | 8167 */ |
| 9448 SimpleIdentifier _propertyName; | 8168 SimpleIdentifier _propertyName; |
| 9449 | 8169 |
| 9450 /** | 8170 /** |
| 9451 * Initialize a newly created property access expression. | 8171 * Initialize a newly created property access expression. |
| 9452 */ | 8172 */ |
| 9453 PropertyAccess( | 8173 PropertyAccessImpl( |
| 9454 Expression target, this.operator, SimpleIdentifier propertyName) { | 8174 Expression target, this.operator, SimpleIdentifier propertyName) { |
| 9455 _target = _becomeParentOf(target); | 8175 _target = _becomeParentOf(target); |
| 9456 _propertyName = _becomeParentOf(propertyName); | 8176 _propertyName = _becomeParentOf(propertyName); |
| 9457 } | 8177 } |
| 9458 | 8178 |
| 9459 @override | 8179 @override |
| 9460 Token get beginToken { | 8180 Token get beginToken { |
| 9461 if (_target != null) { | 8181 if (_target != null) { |
| 9462 return _target.beginToken; | 8182 return _target.beginToken; |
| 9463 } | 8183 } |
| 9464 return operator; | 8184 return operator; |
| 9465 } | 8185 } |
| 9466 | 8186 |
| 9467 @override | 8187 @override |
| 9468 Iterable get childEntities => | 8188 Iterable get childEntities => |
| 9469 new ChildEntities()..add(_target)..add(operator)..add(_propertyName); | 8189 new ChildEntities()..add(_target)..add(operator)..add(_propertyName); |
| 9470 | 8190 |
| 9471 @override | 8191 @override |
| 9472 Token get endToken => _propertyName.endToken; | 8192 Token get endToken => _propertyName.endToken; |
| 9473 | 8193 |
| 9474 @override | 8194 @override |
| 9475 bool get isAssignable => true; | 8195 bool get isAssignable => true; |
| 9476 | 8196 |
| 9477 /** | 8197 @override |
| 9478 * Return `true` if this expression is cascaded. If it is, then the target of | |
| 9479 * this expression is not stored locally but is stored in the nearest ancestor | |
| 9480 * that is a [CascadeExpression]. | |
| 9481 */ | |
| 9482 bool get isCascaded => | 8198 bool get isCascaded => |
| 9483 operator != null && operator.type == TokenType.PERIOD_PERIOD; | 8199 operator != null && operator.type == TokenType.PERIOD_PERIOD; |
| 9484 | 8200 |
| 9485 @override | 8201 @override |
| 9486 int get precedence => 15; | 8202 int get precedence => 15; |
| 9487 | 8203 |
| 9488 /** | 8204 @override |
| 9489 * Return the name of the property being accessed. | |
| 9490 */ | |
| 9491 SimpleIdentifier get propertyName => _propertyName; | 8205 SimpleIdentifier get propertyName => _propertyName; |
| 9492 | 8206 |
| 9493 /** | 8207 @override |
| 9494 * Set the name of the property being accessed to the given [identifier]. | |
| 9495 */ | |
| 9496 void set propertyName(SimpleIdentifier identifier) { | 8208 void set propertyName(SimpleIdentifier identifier) { |
| 9497 _propertyName = _becomeParentOf(identifier); | 8209 _propertyName = _becomeParentOf(identifier); |
| 9498 } | 8210 } |
| 9499 | 8211 |
| 9500 /** | 8212 @override |
| 9501 * Return the expression used to compute the receiver of the invocation. If | |
| 9502 * this invocation is not part of a cascade expression, then this is the same | |
| 9503 * as [target]. If this invocation is part of a cascade expression, then the | |
| 9504 * target stored with the cascade expression is returned. | |
| 9505 */ | |
| 9506 Expression get realTarget { | 8213 Expression get realTarget { |
| 9507 if (isCascaded) { | 8214 if (isCascaded) { |
| 9508 AstNode ancestor = parent; | 8215 AstNode ancestor = parent; |
| 9509 while (ancestor is! CascadeExpression) { | 8216 while (ancestor is! CascadeExpression) { |
| 9510 if (ancestor == null) { | 8217 if (ancestor == null) { |
| 9511 return _target; | 8218 return _target; |
| 9512 } | 8219 } |
| 9513 ancestor = ancestor.parent; | 8220 ancestor = ancestor.parent; |
| 9514 } | 8221 } |
| 9515 return (ancestor as CascadeExpression).target; | 8222 return (ancestor as CascadeExpression).target; |
| 9516 } | 8223 } |
| 9517 return _target; | 8224 return _target; |
| 9518 } | 8225 } |
| 9519 | 8226 |
| 9520 /** | 8227 @override |
| 9521 * Return the expression computing the object defining the property being | |
| 9522 * accessed, or `null` if this property access is part of a cascade expression
. | |
| 9523 * | |
| 9524 * Use [realTarget] to get the target independent of whether this is part of a | |
| 9525 * cascade expression. | |
| 9526 */ | |
| 9527 Expression get target => _target; | 8228 Expression get target => _target; |
| 9528 | 8229 |
| 9529 /** | 8230 @override |
| 9530 * Set the expression computing the object defining the property being | |
| 9531 * accessed to the given [expression]. | |
| 9532 */ | |
| 9533 void set target(Expression expression) { | 8231 void set target(Expression expression) { |
| 9534 _target = _becomeParentOf(expression); | 8232 _target = _becomeParentOf(expression); |
| 9535 } | 8233 } |
| 9536 | 8234 |
| 9537 @override | 8235 @override |
| 9538 accept(AstVisitor visitor) => visitor.visitPropertyAccess(this); | 8236 accept(AstVisitor visitor) => visitor.visitPropertyAccess(this); |
| 9539 | 8237 |
| 9540 @override | 8238 @override |
| 9541 void visitChildren(AstVisitor visitor) { | 8239 void visitChildren(AstVisitor visitor) { |
| 9542 _safelyVisitChild(_target, visitor); | 8240 _safelyVisitChild(_target, visitor); |
| 9543 _safelyVisitChild(_propertyName, visitor); | 8241 _safelyVisitChild(_propertyName, visitor); |
| 9544 } | 8242 } |
| 9545 } | 8243 } |
| 9546 | 8244 |
| 9547 /** | 8245 /** |
| 9548 * The invocation of a constructor in the same class from within a constructor's | 8246 * The invocation of a constructor in the same class from within a constructor's |
| 9549 * initialization list. | 8247 * initialization list. |
| 9550 * | 8248 * |
| 9551 * > redirectingConstructorInvocation ::= | 8249 * > redirectingConstructorInvocation ::= |
| 9552 * > 'this' ('.' identifier)? arguments | 8250 * > 'this' ('.' identifier)? arguments |
| 9553 */ | 8251 */ |
| 9554 class RedirectingConstructorInvocation extends ConstructorInitializer { | 8252 class RedirectingConstructorInvocationImpl extends ConstructorInitializerImpl |
| 8253 implements RedirectingConstructorInvocation { |
| 9555 /** | 8254 /** |
| 9556 * The token for the 'this' keyword. | 8255 * The token for the 'this' keyword. |
| 9557 */ | 8256 */ |
| 9558 Token thisKeyword; | 8257 Token thisKeyword; |
| 9559 | 8258 |
| 9560 /** | 8259 /** |
| 9561 * The token for the period before the name of the constructor that is being | 8260 * The token for the period before the name of the constructor that is being |
| 9562 * invoked, or `null` if the unnamed constructor is being invoked. | 8261 * invoked, or `null` if the unnamed constructor is being invoked. |
| 9563 */ | 8262 */ |
| 9564 Token period; | 8263 Token period; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9579 * information, or `null` if the AST structure has not been resolved or if the | 8278 * information, or `null` if the AST structure has not been resolved or if the |
| 9580 * constructor could not be resolved. | 8279 * constructor could not be resolved. |
| 9581 */ | 8280 */ |
| 9582 ConstructorElement staticElement; | 8281 ConstructorElement staticElement; |
| 9583 | 8282 |
| 9584 /** | 8283 /** |
| 9585 * Initialize a newly created redirecting invocation to invoke the constructor | 8284 * Initialize a newly created redirecting invocation to invoke the constructor |
| 9586 * with the given name with the given arguments. The [constructorName] can be | 8285 * with the given name with the given arguments. The [constructorName] can be |
| 9587 * `null` if the constructor being invoked is the unnamed constructor. | 8286 * `null` if the constructor being invoked is the unnamed constructor. |
| 9588 */ | 8287 */ |
| 9589 RedirectingConstructorInvocation(this.thisKeyword, this.period, | 8288 RedirectingConstructorInvocationImpl(this.thisKeyword, this.period, |
| 9590 SimpleIdentifier constructorName, ArgumentList argumentList) { | 8289 SimpleIdentifier constructorName, ArgumentList argumentList) { |
| 9591 _constructorName = _becomeParentOf(constructorName); | 8290 _constructorName = _becomeParentOf(constructorName); |
| 9592 _argumentList = _becomeParentOf(argumentList); | 8291 _argumentList = _becomeParentOf(argumentList); |
| 9593 } | 8292 } |
| 9594 | 8293 |
| 9595 /** | 8294 @override |
| 9596 * Return the list of arguments to the constructor. | |
| 9597 */ | |
| 9598 ArgumentList get argumentList => _argumentList; | 8295 ArgumentList get argumentList => _argumentList; |
| 9599 | 8296 |
| 9600 /** | 8297 @override |
| 9601 * Set the list of arguments to the constructor to the given [argumentList]. | |
| 9602 */ | |
| 9603 void set argumentList(ArgumentList argumentList) { | 8298 void set argumentList(ArgumentList argumentList) { |
| 9604 _argumentList = _becomeParentOf(argumentList); | 8299 _argumentList = _becomeParentOf(argumentList); |
| 9605 } | 8300 } |
| 9606 | 8301 |
| 9607 @override | 8302 @override |
| 9608 Token get beginToken => thisKeyword; | 8303 Token get beginToken => thisKeyword; |
| 9609 | 8304 |
| 9610 @override | 8305 @override |
| 9611 Iterable get childEntities => new ChildEntities() | 8306 Iterable get childEntities => new ChildEntities() |
| 9612 ..add(thisKeyword) | 8307 ..add(thisKeyword) |
| 9613 ..add(period) | 8308 ..add(period) |
| 9614 ..add(_constructorName) | 8309 ..add(_constructorName) |
| 9615 ..add(_argumentList); | 8310 ..add(_argumentList); |
| 9616 | 8311 |
| 9617 /** | 8312 @override |
| 9618 * Return the name of the constructor that is being invoked, or `null` if the | |
| 9619 * unnamed constructor is being invoked. | |
| 9620 */ | |
| 9621 SimpleIdentifier get constructorName => _constructorName; | 8313 SimpleIdentifier get constructorName => _constructorName; |
| 9622 | 8314 |
| 9623 /** | 8315 @override |
| 9624 * Set the name of the constructor that is being invoked to the given | |
| 9625 * [identifier]. | |
| 9626 */ | |
| 9627 void set constructorName(SimpleIdentifier identifier) { | 8316 void set constructorName(SimpleIdentifier identifier) { |
| 9628 _constructorName = _becomeParentOf(identifier); | 8317 _constructorName = _becomeParentOf(identifier); |
| 9629 } | 8318 } |
| 9630 | 8319 |
| 9631 @override | 8320 @override |
| 9632 Token get endToken => _argumentList.endToken; | 8321 Token get endToken => _argumentList.endToken; |
| 9633 | 8322 |
| 9634 @override | 8323 @override |
| 9635 accept(AstVisitor visitor) => | 8324 accept(AstVisitor visitor) => |
| 9636 visitor.visitRedirectingConstructorInvocation(this); | 8325 visitor.visitRedirectingConstructorInvocation(this); |
| 9637 | 8326 |
| 9638 @override | 8327 @override |
| 9639 void visitChildren(AstVisitor visitor) { | 8328 void visitChildren(AstVisitor visitor) { |
| 9640 _safelyVisitChild(_constructorName, visitor); | 8329 _safelyVisitChild(_constructorName, visitor); |
| 9641 _safelyVisitChild(_argumentList, visitor); | 8330 _safelyVisitChild(_argumentList, visitor); |
| 9642 } | 8331 } |
| 9643 } | 8332 } |
| 9644 | 8333 |
| 9645 /** | 8334 /** |
| 9646 * A rethrow expression. | 8335 * A rethrow expression. |
| 9647 * | 8336 * |
| 9648 * > rethrowExpression ::= | 8337 * > rethrowExpression ::= |
| 9649 * > 'rethrow' | 8338 * > 'rethrow' |
| 9650 */ | 8339 */ |
| 9651 class RethrowExpression extends Expression { | 8340 class RethrowExpressionImpl extends ExpressionImpl |
| 8341 implements RethrowExpression { |
| 9652 /** | 8342 /** |
| 9653 * The token representing the 'rethrow' keyword. | 8343 * The token representing the 'rethrow' keyword. |
| 9654 */ | 8344 */ |
| 9655 Token rethrowKeyword; | 8345 Token rethrowKeyword; |
| 9656 | 8346 |
| 9657 /** | 8347 /** |
| 9658 * Initialize a newly created rethrow expression. | 8348 * Initialize a newly created rethrow expression. |
| 9659 */ | 8349 */ |
| 9660 RethrowExpression(this.rethrowKeyword); | 8350 RethrowExpressionImpl(this.rethrowKeyword); |
| 9661 | 8351 |
| 9662 @override | 8352 @override |
| 9663 Token get beginToken => rethrowKeyword; | 8353 Token get beginToken => rethrowKeyword; |
| 9664 | 8354 |
| 9665 @override | 8355 @override |
| 9666 Iterable get childEntities => new ChildEntities()..add(rethrowKeyword); | 8356 Iterable get childEntities => new ChildEntities()..add(rethrowKeyword); |
| 9667 | 8357 |
| 9668 @override | 8358 @override |
| 9669 Token get endToken => rethrowKeyword; | 8359 Token get endToken => rethrowKeyword; |
| 9670 | 8360 |
| 9671 @override | 8361 @override |
| 9672 int get precedence => 0; | 8362 int get precedence => 0; |
| 9673 | 8363 |
| 9674 @override | 8364 @override |
| 9675 accept(AstVisitor visitor) => visitor.visitRethrowExpression(this); | 8365 accept(AstVisitor visitor) => visitor.visitRethrowExpression(this); |
| 9676 | 8366 |
| 9677 @override | 8367 @override |
| 9678 void visitChildren(AstVisitor visitor) { | 8368 void visitChildren(AstVisitor visitor) { |
| 9679 // There are no children to visit. | 8369 // There are no children to visit. |
| 9680 } | 8370 } |
| 9681 } | 8371 } |
| 9682 | 8372 |
| 9683 /** | 8373 /** |
| 9684 * A return statement. | 8374 * A return statement. |
| 9685 * | 8375 * |
| 9686 * > returnStatement ::= | 8376 * > returnStatement ::= |
| 9687 * > 'return' [Expression]? ';' | 8377 * > 'return' [Expression]? ';' |
| 9688 */ | 8378 */ |
| 9689 class ReturnStatement extends Statement { | 8379 class ReturnStatementImpl extends StatementImpl implements ReturnStatement { |
| 9690 /** | 8380 /** |
| 9691 * The token representing the 'return' keyword. | 8381 * The token representing the 'return' keyword. |
| 9692 */ | 8382 */ |
| 9693 Token returnKeyword; | 8383 Token returnKeyword; |
| 9694 | 8384 |
| 9695 /** | 8385 /** |
| 9696 * The expression computing the value to be returned, or `null` if no explicit | 8386 * The expression computing the value to be returned, or `null` if no explicit |
| 9697 * value was provided. | 8387 * value was provided. |
| 9698 */ | 8388 */ |
| 9699 Expression _expression; | 8389 Expression _expression; |
| 9700 | 8390 |
| 9701 /** | 8391 /** |
| 9702 * The semicolon terminating the statement. | 8392 * The semicolon terminating the statement. |
| 9703 */ | 8393 */ |
| 9704 Token semicolon; | 8394 Token semicolon; |
| 9705 | 8395 |
| 9706 /** | 8396 /** |
| 9707 * Initialize a newly created return statement. The [expression] can be `null` | 8397 * Initialize a newly created return statement. The [expression] can be `null` |
| 9708 * if no explicit value was provided. | 8398 * if no explicit value was provided. |
| 9709 */ | 8399 */ |
| 9710 ReturnStatement(this.returnKeyword, Expression expression, this.semicolon) { | 8400 ReturnStatementImpl( |
| 8401 this.returnKeyword, Expression expression, this.semicolon) { |
| 9711 _expression = _becomeParentOf(expression); | 8402 _expression = _becomeParentOf(expression); |
| 9712 } | 8403 } |
| 9713 | 8404 |
| 9714 @override | 8405 @override |
| 9715 Token get beginToken => returnKeyword; | 8406 Token get beginToken => returnKeyword; |
| 9716 | 8407 |
| 9717 @override | 8408 @override |
| 9718 Iterable get childEntities => | 8409 Iterable get childEntities => |
| 9719 new ChildEntities()..add(returnKeyword)..add(_expression)..add(semicolon); | 8410 new ChildEntities()..add(returnKeyword)..add(_expression)..add(semicolon); |
| 9720 | 8411 |
| 9721 @override | 8412 @override |
| 9722 Token get endToken => semicolon; | 8413 Token get endToken => semicolon; |
| 9723 | 8414 |
| 9724 /** | 8415 @override |
| 9725 * Return the expression computing the value to be returned, or `null` if no | |
| 9726 * explicit value was provided. | |
| 9727 */ | |
| 9728 Expression get expression => _expression; | 8416 Expression get expression => _expression; |
| 9729 | 8417 |
| 9730 /** | 8418 @override |
| 9731 * Set the expression computing the value to be returned to the given | |
| 9732 * [expression]. | |
| 9733 */ | |
| 9734 void set expression(Expression expression) { | 8419 void set expression(Expression expression) { |
| 9735 _expression = _becomeParentOf(expression); | 8420 _expression = _becomeParentOf(expression); |
| 9736 } | 8421 } |
| 9737 | 8422 |
| 9738 @override | 8423 @override |
| 9739 accept(AstVisitor visitor) => visitor.visitReturnStatement(this); | 8424 accept(AstVisitor visitor) => visitor.visitReturnStatement(this); |
| 9740 | 8425 |
| 9741 @override | 8426 @override |
| 9742 void visitChildren(AstVisitor visitor) { | 8427 void visitChildren(AstVisitor visitor) { |
| 9743 _safelyVisitChild(_expression, visitor); | 8428 _safelyVisitChild(_expression, visitor); |
| 9744 } | 8429 } |
| 9745 } | 8430 } |
| 9746 | 8431 |
| 9747 /** | 8432 /** |
| 9748 * A script tag that can optionally occur at the beginning of a compilation unit
. | 8433 * A script tag that can optionally occur at the beginning of a compilation unit
. |
| 9749 * | 8434 * |
| 9750 * > scriptTag ::= | 8435 * > scriptTag ::= |
| 9751 * > '#!' (~NEWLINE)* NEWLINE | 8436 * > '#!' (~NEWLINE)* NEWLINE |
| 9752 */ | 8437 */ |
| 9753 class ScriptTag extends AstNode { | 8438 class ScriptTagImpl extends AstNodeImpl implements ScriptTag { |
| 9754 /** | 8439 /** |
| 9755 * The token representing this script tag. | 8440 * The token representing this script tag. |
| 9756 */ | 8441 */ |
| 9757 Token scriptTag; | 8442 Token scriptTag; |
| 9758 | 8443 |
| 9759 /** | 8444 /** |
| 9760 * Initialize a newly created script tag. | 8445 * Initialize a newly created script tag. |
| 9761 */ | 8446 */ |
| 9762 ScriptTag(this.scriptTag); | 8447 ScriptTagImpl(this.scriptTag); |
| 9763 | 8448 |
| 9764 @override | 8449 @override |
| 9765 Token get beginToken => scriptTag; | 8450 Token get beginToken => scriptTag; |
| 9766 | 8451 |
| 9767 @override | 8452 @override |
| 9768 Iterable get childEntities => new ChildEntities()..add(scriptTag); | 8453 Iterable get childEntities => new ChildEntities()..add(scriptTag); |
| 9769 | 8454 |
| 9770 @override | 8455 @override |
| 9771 Token get endToken => scriptTag; | 8456 Token get endToken => scriptTag; |
| 9772 | 8457 |
| 9773 @override | 8458 @override |
| 9774 accept(AstVisitor visitor) => visitor.visitScriptTag(this); | 8459 accept(AstVisitor visitor) => visitor.visitScriptTag(this); |
| 9775 | 8460 |
| 9776 @override | 8461 @override |
| 9777 void visitChildren(AstVisitor visitor) { | 8462 void visitChildren(AstVisitor visitor) { |
| 9778 // There are no children to visit. | 8463 // There are no children to visit. |
| 9779 } | 8464 } |
| 9780 } | 8465 } |
| 9781 | 8466 |
| 9782 /** | 8467 /** |
| 9783 * A combinator that restricts the names being imported to those in a given list
. | 8468 * A combinator that restricts the names being imported to those in a given list
. |
| 9784 * | 8469 * |
| 9785 * > showCombinator ::= | 8470 * > showCombinator ::= |
| 9786 * > 'show' [SimpleIdentifier] (',' [SimpleIdentifier])* | 8471 * > 'show' [SimpleIdentifier] (',' [SimpleIdentifier])* |
| 9787 */ | 8472 */ |
| 9788 class ShowCombinator extends Combinator { | 8473 class ShowCombinatorImpl extends CombinatorImpl implements ShowCombinator { |
| 9789 /** | 8474 /** |
| 9790 * The list of names from the library that are made visible by this combinator
. | 8475 * The list of names from the library that are made visible by this combinator
. |
| 9791 */ | 8476 */ |
| 9792 NodeList<SimpleIdentifier> _shownNames; | 8477 NodeList<SimpleIdentifier> _shownNames; |
| 9793 | 8478 |
| 9794 /** | 8479 /** |
| 9795 * Initialize a newly created import show combinator. | 8480 * Initialize a newly created import show combinator. |
| 9796 */ | 8481 */ |
| 9797 ShowCombinator(Token keyword, List<SimpleIdentifier> shownNames) | 8482 ShowCombinatorImpl(Token keyword, List<SimpleIdentifier> shownNames) |
| 9798 : super(keyword) { | 8483 : super(keyword) { |
| 9799 _shownNames = new NodeList<SimpleIdentifier>(this, shownNames); | 8484 _shownNames = new NodeList<SimpleIdentifier>(this, shownNames); |
| 9800 } | 8485 } |
| 9801 | 8486 |
| 9802 @override | 8487 @override |
| 9803 // TODO(paulberry): add commas. | 8488 // TODO(paulberry): add commas. |
| 9804 Iterable get childEntities => new ChildEntities() | 8489 Iterable get childEntities => new ChildEntities() |
| 9805 ..add(keyword) | 8490 ..add(keyword) |
| 9806 ..addAll(_shownNames); | 8491 ..addAll(_shownNames); |
| 9807 | 8492 |
| 9808 @override | 8493 @override |
| 9809 Token get endToken => _shownNames.endToken; | 8494 Token get endToken => _shownNames.endToken; |
| 9810 | 8495 |
| 9811 /** | 8496 @override |
| 9812 * Return the list of names from the library that are made visible by this | |
| 9813 * combinator. | |
| 9814 */ | |
| 9815 NodeList<SimpleIdentifier> get shownNames => _shownNames; | 8497 NodeList<SimpleIdentifier> get shownNames => _shownNames; |
| 9816 | 8498 |
| 9817 @override | 8499 @override |
| 9818 accept(AstVisitor visitor) => visitor.visitShowCombinator(this); | 8500 accept(AstVisitor visitor) => visitor.visitShowCombinator(this); |
| 9819 | 8501 |
| 9820 @override | 8502 @override |
| 9821 void visitChildren(AstVisitor visitor) { | 8503 void visitChildren(AstVisitor visitor) { |
| 9822 _shownNames.accept(visitor); | 8504 _shownNames.accept(visitor); |
| 9823 } | 8505 } |
| 9824 } | 8506 } |
| 9825 | 8507 |
| 9826 /** | 8508 /** |
| 9827 * A simple formal parameter. | 8509 * A simple formal parameter. |
| 9828 * | 8510 * |
| 9829 * > simpleFormalParameter ::= | 8511 * > simpleFormalParameter ::= |
| 9830 * > ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier] | 8512 * > ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier] |
| 9831 */ | 8513 */ |
| 9832 class SimpleFormalParameter extends NormalFormalParameter { | 8514 class SimpleFormalParameterImpl extends NormalFormalParameterImpl |
| 8515 implements SimpleFormalParameter { |
| 9833 /** | 8516 /** |
| 9834 * The token representing either the 'final', 'const' or 'var' keyword, or | 8517 * The token representing either the 'final', 'const' or 'var' keyword, or |
| 9835 * `null` if no keyword was used. | 8518 * `null` if no keyword was used. |
| 9836 */ | 8519 */ |
| 9837 Token keyword; | 8520 Token keyword; |
| 9838 | 8521 |
| 9839 /** | 8522 /** |
| 9840 * The name of the declared type of the parameter, or `null` if the parameter | 8523 * The name of the declared type of the parameter, or `null` if the parameter |
| 9841 * does not have a declared type. | 8524 * does not have a declared type. |
| 9842 */ | 8525 */ |
| 9843 TypeName _type; | 8526 TypeName _type; |
| 9844 | 8527 |
| 9845 /** | 8528 /** |
| 9846 * Initialize a newly created formal parameter. Either or both of the | 8529 * Initialize a newly created formal parameter. Either or both of the |
| 9847 * [comment] and [metadata] can be `null` if the parameter does not have the | 8530 * [comment] and [metadata] can be `null` if the parameter does not have the |
| 9848 * corresponding attribute. The [keyword] can be `null` if a type was | 8531 * corresponding attribute. The [keyword] can be `null` if a type was |
| 9849 * specified. The [type] must be `null` if the keyword is 'var'. | 8532 * specified. The [type] must be `null` if the keyword is 'var'. |
| 9850 */ | 8533 */ |
| 9851 SimpleFormalParameter(Comment comment, List<Annotation> metadata, | 8534 SimpleFormalParameterImpl(Comment comment, List<Annotation> metadata, |
| 9852 this.keyword, TypeName type, SimpleIdentifier identifier) | 8535 this.keyword, TypeName type, SimpleIdentifier identifier) |
| 9853 : super(comment, metadata, identifier) { | 8536 : super(comment, metadata, identifier) { |
| 9854 _type = _becomeParentOf(type); | 8537 _type = _becomeParentOf(type); |
| 9855 } | 8538 } |
| 9856 | 8539 |
| 9857 @override | 8540 @override |
| 9858 Token get beginToken { | 8541 Token get beginToken { |
| 9859 NodeList<Annotation> metadata = this.metadata; | 8542 NodeList<Annotation> metadata = this.metadata; |
| 9860 if (!metadata.isEmpty) { | 8543 if (!metadata.isEmpty) { |
| 9861 return metadata.beginToken; | 8544 return metadata.beginToken; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9877 @override | 8560 @override |
| 9878 bool get isConst => | 8561 bool get isConst => |
| 9879 (keyword is KeywordToken) && | 8562 (keyword is KeywordToken) && |
| 9880 (keyword as KeywordToken).keyword == Keyword.CONST; | 8563 (keyword as KeywordToken).keyword == Keyword.CONST; |
| 9881 | 8564 |
| 9882 @override | 8565 @override |
| 9883 bool get isFinal => | 8566 bool get isFinal => |
| 9884 (keyword is KeywordToken) && | 8567 (keyword is KeywordToken) && |
| 9885 (keyword as KeywordToken).keyword == Keyword.FINAL; | 8568 (keyword as KeywordToken).keyword == Keyword.FINAL; |
| 9886 | 8569 |
| 9887 /** | 8570 @override |
| 9888 * Return the name of the declared type of the parameter, or `null` if the | |
| 9889 * parameter does not have a declared type. | |
| 9890 */ | |
| 9891 TypeName get type => _type; | 8571 TypeName get type => _type; |
| 9892 | 8572 |
| 9893 /** | 8573 @override |
| 9894 * Set the name of the declared type of the parameter to the given [typeName]. | |
| 9895 */ | |
| 9896 void set type(TypeName typeName) { | 8574 void set type(TypeName typeName) { |
| 9897 _type = _becomeParentOf(typeName); | 8575 _type = _becomeParentOf(typeName); |
| 9898 } | 8576 } |
| 9899 | 8577 |
| 9900 @override | 8578 @override |
| 9901 accept(AstVisitor visitor) => visitor.visitSimpleFormalParameter(this); | 8579 accept(AstVisitor visitor) => visitor.visitSimpleFormalParameter(this); |
| 9902 | 8580 |
| 9903 @override | 8581 @override |
| 9904 void visitChildren(AstVisitor visitor) { | 8582 void visitChildren(AstVisitor visitor) { |
| 9905 super.visitChildren(visitor); | 8583 super.visitChildren(visitor); |
| 9906 _safelyVisitChild(_type, visitor); | 8584 _safelyVisitChild(_type, visitor); |
| 9907 _safelyVisitChild(identifier, visitor); | 8585 _safelyVisitChild(identifier, visitor); |
| 9908 } | 8586 } |
| 9909 } | 8587 } |
| 9910 | 8588 |
| 9911 /** | 8589 /** |
| 9912 * A simple identifier. | 8590 * A simple identifier. |
| 9913 * | 8591 * |
| 9914 * > simpleIdentifier ::= | 8592 * > simpleIdentifier ::= |
| 9915 * > initialCharacter internalCharacter* | 8593 * > initialCharacter internalCharacter* |
| 9916 * > | 8594 * > |
| 9917 * > initialCharacter ::= '_' | '$' | letter | 8595 * > initialCharacter ::= '_' | '$' | letter |
| 9918 * > | 8596 * > |
| 9919 * > internalCharacter ::= '_' | '$' | letter | digit | 8597 * > internalCharacter ::= '_' | '$' | letter | digit |
| 9920 */ | 8598 */ |
| 9921 class SimpleIdentifier extends Identifier { | 8599 class SimpleIdentifierImpl extends IdentifierImpl implements SimpleIdentifier { |
| 9922 /** | 8600 /** |
| 9923 * The token representing the identifier. | 8601 * The token representing the identifier. |
| 9924 */ | 8602 */ |
| 9925 Token token; | 8603 Token token; |
| 9926 | 8604 |
| 9927 /** | 8605 /** |
| 9928 * The element associated with this identifier based on static type | 8606 * The element associated with this identifier based on static type |
| 9929 * information, or `null` if the AST structure has not been resolved or if | 8607 * information, or `null` if the AST structure has not been resolved or if |
| 9930 * this identifier could not be resolved. | 8608 * this identifier could not be resolved. |
| 9931 */ | 8609 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9942 * If this expression is both in a getter and setter context, the | 8620 * If this expression is both in a getter and setter context, the |
| 9943 * [AuxiliaryElements] will be set to hold onto the static and propagated | 8621 * [AuxiliaryElements] will be set to hold onto the static and propagated |
| 9944 * information. The auxiliary element will hold onto the elements from the | 8622 * information. The auxiliary element will hold onto the elements from the |
| 9945 * getter context. | 8623 * getter context. |
| 9946 */ | 8624 */ |
| 9947 AuxiliaryElements auxiliaryElements = null; | 8625 AuxiliaryElements auxiliaryElements = null; |
| 9948 | 8626 |
| 9949 /** | 8627 /** |
| 9950 * Initialize a newly created identifier. | 8628 * Initialize a newly created identifier. |
| 9951 */ | 8629 */ |
| 9952 SimpleIdentifier(this.token); | 8630 SimpleIdentifierImpl(this.token); |
| 9953 | 8631 |
| 9954 @override | 8632 @override |
| 9955 Token get beginToken => token; | 8633 Token get beginToken => token; |
| 9956 | 8634 |
| 9957 @override | 8635 @override |
| 9958 Element get bestElement { | 8636 Element get bestElement { |
| 9959 if (_propagatedElement == null) { | 8637 if (_propagatedElement == null) { |
| 9960 return _staticElement; | 8638 return _staticElement; |
| 9961 } | 8639 } |
| 9962 return _propagatedElement; | 8640 return _propagatedElement; |
| 9963 } | 8641 } |
| 9964 | 8642 |
| 9965 @override | 8643 @override |
| 9966 Iterable get childEntities => new ChildEntities()..add(token); | 8644 Iterable get childEntities => new ChildEntities()..add(token); |
| 9967 | 8645 |
| 9968 @override | 8646 @override |
| 9969 Token get endToken => token; | 8647 Token get endToken => token; |
| 9970 | 8648 |
| 9971 /** | 8649 @override |
| 9972 * Return `true` if this identifier is the "name" part of a prefixed | |
| 9973 * identifier or a method invocation. | |
| 9974 */ | |
| 9975 bool get isQualified { | 8650 bool get isQualified { |
| 9976 AstNode parent = this.parent; | 8651 AstNode parent = this.parent; |
| 9977 if (parent is PrefixedIdentifier) { | 8652 if (parent is PrefixedIdentifier) { |
| 9978 return identical(parent.identifier, this); | 8653 return identical(parent.identifier, this); |
| 9979 } | 8654 } |
| 9980 if (parent is PropertyAccess) { | 8655 if (parent is PropertyAccess) { |
| 9981 return identical(parent.propertyName, this); | 8656 return identical(parent.propertyName, this); |
| 9982 } | 8657 } |
| 9983 if (parent is MethodInvocation) { | 8658 if (parent is MethodInvocation) { |
| 9984 MethodInvocation invocation = parent; | 8659 MethodInvocation invocation = parent; |
| 9985 return identical(invocation.methodName, this) && | 8660 return identical(invocation.methodName, this) && |
| 9986 invocation.realTarget != null; | 8661 invocation.realTarget != null; |
| 9987 } | 8662 } |
| 9988 return false; | 8663 return false; |
| 9989 } | 8664 } |
| 9990 | 8665 |
| 9991 @override | 8666 @override |
| 9992 bool get isSynthetic => token.isSynthetic; | 8667 bool get isSynthetic => token.isSynthetic; |
| 9993 | 8668 |
| 9994 @override | 8669 @override |
| 9995 String get name => token.lexeme; | 8670 String get name => token.lexeme; |
| 9996 | 8671 |
| 9997 @override | 8672 @override |
| 9998 int get precedence => 16; | 8673 int get precedence => 16; |
| 9999 | 8674 |
| 10000 @override | 8675 @override |
| 10001 Element get propagatedElement => _propagatedElement; | 8676 Element get propagatedElement => _propagatedElement; |
| 10002 | 8677 |
| 10003 /** | 8678 @override |
| 10004 * Set the element associated with this identifier based on propagated type | |
| 10005 * information to the given [element]. | |
| 10006 */ | |
| 10007 void set propagatedElement(Element element) { | 8679 void set propagatedElement(Element element) { |
| 10008 _propagatedElement = _validateElement(element); | 8680 _propagatedElement = _validateElement(element); |
| 10009 } | 8681 } |
| 10010 | 8682 |
| 10011 @override | 8683 @override |
| 10012 Element get staticElement => _staticElement; | 8684 Element get staticElement => _staticElement; |
| 10013 | 8685 |
| 10014 /** | 8686 @override |
| 10015 * Set the element associated with this identifier based on static type | |
| 10016 * information to the given [element]. | |
| 10017 */ | |
| 10018 void set staticElement(Element element) { | 8687 void set staticElement(Element element) { |
| 10019 _staticElement = _validateElement(element); | 8688 _staticElement = _validateElement(element); |
| 10020 } | 8689 } |
| 10021 | 8690 |
| 10022 @override | 8691 @override |
| 10023 accept(AstVisitor visitor) => visitor.visitSimpleIdentifier(this); | 8692 accept(AstVisitor visitor) => visitor.visitSimpleIdentifier(this); |
| 10024 | 8693 |
| 10025 /** | 8694 @override |
| 10026 * Return `true` if this identifier is the name being declared in a | |
| 10027 * declaration. | |
| 10028 */ | |
| 10029 bool inDeclarationContext() { | 8695 bool inDeclarationContext() { |
| 10030 // TODO(brianwilkerson) Convert this to a getter. | 8696 // TODO(brianwilkerson) Convert this to a getter. |
| 10031 AstNode parent = this.parent; | 8697 AstNode parent = this.parent; |
| 10032 if (parent is CatchClause) { | 8698 if (parent is CatchClause) { |
| 10033 CatchClause clause = parent; | 8699 CatchClause clause = parent; |
| 10034 return identical(this, clause.exceptionParameter) || | 8700 return identical(this, clause.exceptionParameter) || |
| 10035 identical(this, clause.stackTraceParameter); | 8701 identical(this, clause.stackTraceParameter); |
| 10036 } else if (parent is ClassDeclaration) { | 8702 } else if (parent is ClassDeclaration) { |
| 10037 return identical(this, parent.name); | 8703 return identical(this, parent.name); |
| 10038 } else if (parent is ClassTypeAlias) { | 8704 } else if (parent is ClassTypeAlias) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 10060 parent is SimpleFormalParameter) { | 8726 parent is SimpleFormalParameter) { |
| 10061 return identical(this, (parent as NormalFormalParameter).identifier); | 8727 return identical(this, (parent as NormalFormalParameter).identifier); |
| 10062 } else if (parent is TypeParameter) { | 8728 } else if (parent is TypeParameter) { |
| 10063 return identical(this, parent.name); | 8729 return identical(this, parent.name); |
| 10064 } else if (parent is VariableDeclaration) { | 8730 } else if (parent is VariableDeclaration) { |
| 10065 return identical(this, parent.name); | 8731 return identical(this, parent.name); |
| 10066 } | 8732 } |
| 10067 return false; | 8733 return false; |
| 10068 } | 8734 } |
| 10069 | 8735 |
| 10070 /** | 8736 @override |
| 10071 * Return `true` if this expression is computing a right-hand value. | |
| 10072 * | |
| 10073 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor | |
| 10074 * are they mutually exclusive. In other words, it is possible for both | |
| 10075 * methods to return `true` when invoked on the same node. | |
| 10076 */ | |
| 10077 bool inGetterContext() { | 8737 bool inGetterContext() { |
| 10078 // TODO(brianwilkerson) Convert this to a getter. | 8738 // TODO(brianwilkerson) Convert this to a getter. |
| 10079 AstNode parent = this.parent; | 8739 AstNode parent = this.parent; |
| 10080 AstNode target = this; | 8740 AstNode target = this; |
| 10081 // skip prefix | 8741 // skip prefix |
| 10082 if (parent is PrefixedIdentifier) { | 8742 if (parent is PrefixedIdentifier) { |
| 10083 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; | 8743 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; |
| 10084 if (identical(prefixed.prefix, this)) { | 8744 if (identical(prefixed.prefix, this)) { |
| 10085 return true; | 8745 return true; |
| 10086 } | 8746 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 10106 } | 8766 } |
| 10107 } | 8767 } |
| 10108 if (parent is ForEachStatement) { | 8768 if (parent is ForEachStatement) { |
| 10109 if (identical(parent.identifier, target)) { | 8769 if (identical(parent.identifier, target)) { |
| 10110 return false; | 8770 return false; |
| 10111 } | 8771 } |
| 10112 } | 8772 } |
| 10113 return true; | 8773 return true; |
| 10114 } | 8774 } |
| 10115 | 8775 |
| 10116 /** | 8776 @override |
| 10117 * Return `true` if this expression is computing a left-hand value. | |
| 10118 * | |
| 10119 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor | |
| 10120 * are they mutually exclusive. In other words, it is possible for both | |
| 10121 * methods to return `true` when invoked on the same node. | |
| 10122 */ | |
| 10123 bool inSetterContext() { | 8777 bool inSetterContext() { |
| 10124 // TODO(brianwilkerson) Convert this to a getter. | 8778 // TODO(brianwilkerson) Convert this to a getter. |
| 10125 AstNode parent = this.parent; | 8779 AstNode parent = this.parent; |
| 10126 AstNode target = this; | 8780 AstNode target = this; |
| 10127 // skip prefix | 8781 // skip prefix |
| 10128 if (parent is PrefixedIdentifier) { | 8782 if (parent is PrefixedIdentifier) { |
| 10129 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; | 8783 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; |
| 10130 // if this is the prefix, then return false | 8784 // if this is the prefix, then return false |
| 10131 if (identical(prefixed.prefix, this)) { | 8785 if (identical(prefixed.prefix, this)) { |
| 10132 return false; | 8786 return false; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10235 * > | singleLineStringLiteral | 8889 * > | singleLineStringLiteral |
| 10236 * > | 8890 * > |
| 10237 * > multiLineStringLiteral ::= | 8891 * > multiLineStringLiteral ::= |
| 10238 * > "'''" characters "'''" | 8892 * > "'''" characters "'''" |
| 10239 * > | '"""' characters '"""' | 8893 * > | '"""' characters '"""' |
| 10240 * > | 8894 * > |
| 10241 * > singleLineStringLiteral ::= | 8895 * > singleLineStringLiteral ::= |
| 10242 * > "'" characters "'" | 8896 * > "'" characters "'" |
| 10243 * > | '"' characters '"' | 8897 * > | '"' characters '"' |
| 10244 */ | 8898 */ |
| 10245 class SimpleStringLiteral extends SingleStringLiteral { | 8899 class SimpleStringLiteralImpl extends SingleStringLiteralImpl |
| 8900 implements SimpleStringLiteral { |
| 10246 /** | 8901 /** |
| 10247 * The token representing the literal. | 8902 * The token representing the literal. |
| 10248 */ | 8903 */ |
| 10249 Token literal; | 8904 Token literal; |
| 10250 | 8905 |
| 10251 /** | 8906 /** |
| 10252 * The value of the literal. | 8907 * The value of the literal. |
| 10253 */ | 8908 */ |
| 10254 String _value; | 8909 String _value; |
| 10255 | 8910 |
| 10256 /** | 8911 /** |
| 10257 * Initialize a newly created simple string literal. | 8912 * Initialize a newly created simple string literal. |
| 10258 */ | 8913 */ |
| 10259 SimpleStringLiteral(this.literal, String value) { | 8914 SimpleStringLiteralImpl(this.literal, String value) { |
| 10260 _value = StringUtilities.intern(value); | 8915 _value = StringUtilities.intern(value); |
| 10261 } | 8916 } |
| 10262 | 8917 |
| 10263 @override | 8918 @override |
| 10264 Token get beginToken => literal; | 8919 Token get beginToken => literal; |
| 10265 | 8920 |
| 10266 @override | 8921 @override |
| 10267 Iterable get childEntities => new ChildEntities()..add(literal); | 8922 Iterable get childEntities => new ChildEntities()..add(literal); |
| 10268 | 8923 |
| 10269 @override | 8924 @override |
| (...skipping 10 matching lines...) Expand all Loading... |
| 10280 | 8935 |
| 10281 @override | 8936 @override |
| 10282 bool get isRaw => _helper.isRaw; | 8937 bool get isRaw => _helper.isRaw; |
| 10283 | 8938 |
| 10284 @override | 8939 @override |
| 10285 bool get isSingleQuoted => _helper.isSingleQuoted; | 8940 bool get isSingleQuoted => _helper.isSingleQuoted; |
| 10286 | 8941 |
| 10287 @override | 8942 @override |
| 10288 bool get isSynthetic => literal.isSynthetic; | 8943 bool get isSynthetic => literal.isSynthetic; |
| 10289 | 8944 |
| 10290 /** | 8945 @override |
| 10291 * Return the value of the literal. | |
| 10292 */ | |
| 10293 String get value => _value; | 8946 String get value => _value; |
| 10294 | 8947 |
| 10295 /** | 8948 @override |
| 10296 * Set the value of the literal to the given [string]. | |
| 10297 */ | |
| 10298 void set value(String string) { | 8949 void set value(String string) { |
| 10299 _value = StringUtilities.intern(_value); | 8950 _value = StringUtilities.intern(_value); |
| 10300 } | 8951 } |
| 10301 | 8952 |
| 10302 StringLexemeHelper get _helper { | 8953 StringLexemeHelper get _helper { |
| 10303 return new StringLexemeHelper(literal.lexeme, true, true); | 8954 return new StringLexemeHelper(literal.lexeme, true, true); |
| 10304 } | 8955 } |
| 10305 | 8956 |
| 10306 @override | 8957 @override |
| 10307 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this); | 8958 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this); |
| 10308 | 8959 |
| 10309 @override | 8960 @override |
| 10310 void visitChildren(AstVisitor visitor) { | 8961 void visitChildren(AstVisitor visitor) { |
| 10311 // There are no children to visit. | 8962 // There are no children to visit. |
| 10312 } | 8963 } |
| 10313 | 8964 |
| 10314 @override | 8965 @override |
| 10315 void _appendStringValue(StringBuffer buffer) { | 8966 void _appendStringValue(StringBuffer buffer) { |
| 10316 buffer.write(value); | 8967 buffer.write(value); |
| 10317 } | 8968 } |
| 10318 } | 8969 } |
| 10319 | 8970 |
| 10320 /** | 8971 /** |
| 10321 * A single string literal expression. | 8972 * A single string literal expression. |
| 10322 * | 8973 * |
| 10323 * > singleStringLiteral ::= | 8974 * > singleStringLiteral ::= |
| 10324 * > [SimpleStringLiteral] | 8975 * > [SimpleStringLiteral] |
| 10325 * > | [StringInterpolation] | 8976 * > | [StringInterpolation] |
| 10326 */ | 8977 */ |
| 10327 abstract class SingleStringLiteral extends StringLiteral { | 8978 abstract class SingleStringLiteralImpl extends StringLiteralImpl |
| 10328 /** | 8979 implements SingleStringLiteral {} |
| 10329 * Return the offset of the after-last contents character. | |
| 10330 */ | |
| 10331 int get contentsEnd; | |
| 10332 | |
| 10333 /** | |
| 10334 * Return the offset of the first contents character. | |
| 10335 * If the string is multiline, then leading whitespaces are skipped. | |
| 10336 */ | |
| 10337 int get contentsOffset; | |
| 10338 | |
| 10339 /** | |
| 10340 * Return `true` if this string literal is a multi-line string. | |
| 10341 */ | |
| 10342 bool get isMultiline; | |
| 10343 | |
| 10344 /** | |
| 10345 * Return `true` if this string literal is a raw string. | |
| 10346 */ | |
| 10347 bool get isRaw; | |
| 10348 | |
| 10349 /** | |
| 10350 * Return `true` if this string literal uses single quotes (' or '''). | |
| 10351 * Return `false` if this string literal uses double quotes (" or """). | |
| 10352 */ | |
| 10353 bool get isSingleQuoted; | |
| 10354 } | |
| 10355 | 8980 |
| 10356 /** | 8981 /** |
| 10357 * A node that represents a statement. | 8982 * A node that represents a statement. |
| 10358 * | 8983 * |
| 10359 * > statement ::= | 8984 * > statement ::= |
| 10360 * > [Block] | 8985 * > [Block] |
| 10361 * > | [VariableDeclarationStatement] | 8986 * > | [VariableDeclarationStatement] |
| 10362 * > | [ForStatement] | 8987 * > | [ForStatement] |
| 10363 * > | [ForEachStatement] | 8988 * > | [ForEachStatement] |
| 10364 * > | [WhileStatement] | 8989 * > | [WhileStatement] |
| 10365 * > | [DoStatement] | 8990 * > | [DoStatement] |
| 10366 * > | [SwitchStatement] | 8991 * > | [SwitchStatement] |
| 10367 * > | [IfStatement] | 8992 * > | [IfStatement] |
| 10368 * > | [TryStatement] | 8993 * > | [TryStatement] |
| 10369 * > | [BreakStatement] | 8994 * > | [BreakStatement] |
| 10370 * > | [ContinueStatement] | 8995 * > | [ContinueStatement] |
| 10371 * > | [ReturnStatement] | 8996 * > | [ReturnStatement] |
| 10372 * > | [ExpressionStatement] | 8997 * > | [ExpressionStatement] |
| 10373 * > | [FunctionDeclarationStatement] | 8998 * > | [FunctionDeclarationStatement] |
| 10374 */ | 8999 */ |
| 10375 abstract class Statement extends AstNode { | 9000 abstract class StatementImpl extends AstNodeImpl implements Statement { |
| 10376 /** | 9001 @override |
| 10377 * If this is a labeled statement, return the unlabeled portion of the | |
| 10378 * statement. Otherwise return the statement itself. | |
| 10379 */ | |
| 10380 Statement get unlabeled => this; | 9002 Statement get unlabeled => this; |
| 10381 } | 9003 } |
| 10382 | 9004 |
| 10383 /** | 9005 /** |
| 10384 * A string interpolation literal. | 9006 * A string interpolation literal. |
| 10385 * | 9007 * |
| 10386 * > stringInterpolation ::= | 9008 * > stringInterpolation ::= |
| 10387 * > ''' [InterpolationElement]* ''' | 9009 * > ''' [InterpolationElement]* ''' |
| 10388 * > | '"' [InterpolationElement]* '"' | 9010 * > | '"' [InterpolationElement]* '"' |
| 10389 */ | 9011 */ |
| 10390 class StringInterpolation extends SingleStringLiteral { | 9012 class StringInterpolationImpl extends SingleStringLiteralImpl |
| 9013 implements StringInterpolation { |
| 10391 /** | 9014 /** |
| 10392 * The elements that will be composed to produce the resulting string. | 9015 * The elements that will be composed to produce the resulting string. |
| 10393 */ | 9016 */ |
| 10394 NodeList<InterpolationElement> _elements; | 9017 NodeList<InterpolationElement> _elements; |
| 10395 | 9018 |
| 10396 /** | 9019 /** |
| 10397 * Initialize a newly created string interpolation expression. | 9020 * Initialize a newly created string interpolation expression. |
| 10398 */ | 9021 */ |
| 10399 StringInterpolation(List<InterpolationElement> elements) { | 9022 StringInterpolationImpl(List<InterpolationElement> elements) { |
| 10400 _elements = new NodeList<InterpolationElement>(this, elements); | 9023 _elements = new NodeList<InterpolationElement>(this, elements); |
| 10401 } | 9024 } |
| 10402 | 9025 |
| 10403 @override | 9026 @override |
| 10404 Token get beginToken => _elements.beginToken; | 9027 Token get beginToken => _elements.beginToken; |
| 10405 | 9028 |
| 10406 @override | 9029 @override |
| 10407 Iterable get childEntities => new ChildEntities()..addAll(_elements); | 9030 Iterable get childEntities => new ChildEntities()..addAll(_elements); |
| 10408 | 9031 |
| 10409 @override | 9032 @override |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10551 } | 9174 } |
| 10552 | 9175 |
| 10553 /** | 9176 /** |
| 10554 * A string literal expression. | 9177 * A string literal expression. |
| 10555 * | 9178 * |
| 10556 * > stringLiteral ::= | 9179 * > stringLiteral ::= |
| 10557 * > [SimpleStringLiteral] | 9180 * > [SimpleStringLiteral] |
| 10558 * > | [AdjacentStrings] | 9181 * > | [AdjacentStrings] |
| 10559 * > | [StringInterpolation] | 9182 * > | [StringInterpolation] |
| 10560 */ | 9183 */ |
| 10561 abstract class StringLiteral extends Literal { | 9184 abstract class StringLiteralImpl extends LiteralImpl implements StringLiteral { |
| 10562 /** | 9185 @override |
| 10563 * Return the value of the string literal, or `null` if the string is not a | |
| 10564 * constant string without any string interpolation. | |
| 10565 */ | |
| 10566 String get stringValue { | 9186 String get stringValue { |
| 10567 StringBuffer buffer = new StringBuffer(); | 9187 StringBuffer buffer = new StringBuffer(); |
| 10568 try { | 9188 try { |
| 10569 _appendStringValue(buffer); | 9189 _appendStringValue(buffer); |
| 10570 } on IllegalArgumentException { | 9190 } on IllegalArgumentException { |
| 10571 return null; | 9191 return null; |
| 10572 } | 9192 } |
| 10573 return buffer.toString(); | 9193 return buffer.toString(); |
| 10574 } | 9194 } |
| 10575 | 9195 |
| 10576 /** | 9196 /** |
| 10577 * Append the value of this string literal to the given [buffer]. Throw an | 9197 * Append the value of this string literal to the given [buffer]. Throw an |
| 10578 * [IllegalArgumentException] if the string is not a constant string without | 9198 * [IllegalArgumentException] if the string is not a constant string without |
| 10579 * any string interpolation. | 9199 * any string interpolation. |
| 10580 */ | 9200 */ |
| 10581 void _appendStringValue(StringBuffer buffer); | 9201 void _appendStringValue(StringBuffer buffer); |
| 10582 } | 9202 } |
| 10583 | 9203 |
| 10584 /** | 9204 /** |
| 10585 * The invocation of a superclass' constructor from within a constructor's | 9205 * The invocation of a superclass' constructor from within a constructor's |
| 10586 * initialization list. | 9206 * initialization list. |
| 10587 * | 9207 * |
| 10588 * > superInvocation ::= | 9208 * > superInvocation ::= |
| 10589 * > 'super' ('.' [SimpleIdentifier])? [ArgumentList] | 9209 * > 'super' ('.' [SimpleIdentifier])? [ArgumentList] |
| 10590 */ | 9210 */ |
| 10591 class SuperConstructorInvocation extends ConstructorInitializer { | 9211 class SuperConstructorInvocationImpl extends ConstructorInitializerImpl |
| 9212 implements SuperConstructorInvocation { |
| 10592 /** | 9213 /** |
| 10593 * The token for the 'super' keyword. | 9214 * The token for the 'super' keyword. |
| 10594 */ | 9215 */ |
| 10595 Token superKeyword; | 9216 Token superKeyword; |
| 10596 | 9217 |
| 10597 /** | 9218 /** |
| 10598 * The token for the period before the name of the constructor that is being | 9219 * The token for the period before the name of the constructor that is being |
| 10599 * invoked, or `null` if the unnamed constructor is being invoked. | 9220 * invoked, or `null` if the unnamed constructor is being invoked. |
| 10600 */ | 9221 */ |
| 10601 Token period; | 9222 Token period; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 10617 * constructor could not be resolved. | 9238 * constructor could not be resolved. |
| 10618 */ | 9239 */ |
| 10619 ConstructorElement staticElement; | 9240 ConstructorElement staticElement; |
| 10620 | 9241 |
| 10621 /** | 9242 /** |
| 10622 * Initialize a newly created super invocation to invoke the inherited | 9243 * Initialize a newly created super invocation to invoke the inherited |
| 10623 * constructor with the given name with the given arguments. The [period] and | 9244 * constructor with the given name with the given arguments. The [period] and |
| 10624 * [constructorName] can be `null` if the constructor being invoked is the | 9245 * [constructorName] can be `null` if the constructor being invoked is the |
| 10625 * unnamed constructor. | 9246 * unnamed constructor. |
| 10626 */ | 9247 */ |
| 10627 SuperConstructorInvocation(this.superKeyword, this.period, | 9248 SuperConstructorInvocationImpl(this.superKeyword, this.period, |
| 10628 SimpleIdentifier constructorName, ArgumentList argumentList) { | 9249 SimpleIdentifier constructorName, ArgumentList argumentList) { |
| 10629 _constructorName = _becomeParentOf(constructorName); | 9250 _constructorName = _becomeParentOf(constructorName); |
| 10630 _argumentList = _becomeParentOf(argumentList); | 9251 _argumentList = _becomeParentOf(argumentList); |
| 10631 } | 9252 } |
| 10632 | 9253 |
| 10633 /** | 9254 @override |
| 10634 * Return the list of arguments to the constructor. | |
| 10635 */ | |
| 10636 ArgumentList get argumentList => _argumentList; | 9255 ArgumentList get argumentList => _argumentList; |
| 10637 | 9256 |
| 10638 /** | 9257 @override |
| 10639 * Set the list of arguments to the constructor to the given [argumentList]. | |
| 10640 */ | |
| 10641 void set argumentList(ArgumentList argumentList) { | 9258 void set argumentList(ArgumentList argumentList) { |
| 10642 _argumentList = _becomeParentOf(argumentList); | 9259 _argumentList = _becomeParentOf(argumentList); |
| 10643 } | 9260 } |
| 10644 | 9261 |
| 10645 @override | 9262 @override |
| 10646 Token get beginToken => superKeyword; | 9263 Token get beginToken => superKeyword; |
| 10647 | 9264 |
| 10648 @override | 9265 @override |
| 10649 Iterable get childEntities => new ChildEntities() | 9266 Iterable get childEntities => new ChildEntities() |
| 10650 ..add(superKeyword) | 9267 ..add(superKeyword) |
| 10651 ..add(period) | 9268 ..add(period) |
| 10652 ..add(_constructorName) | 9269 ..add(_constructorName) |
| 10653 ..add(_argumentList); | 9270 ..add(_argumentList); |
| 10654 | 9271 |
| 10655 /** | 9272 @override |
| 10656 * Return the name of the constructor that is being invoked, or `null` if the | |
| 10657 * unnamed constructor is being invoked. | |
| 10658 */ | |
| 10659 SimpleIdentifier get constructorName => _constructorName; | 9273 SimpleIdentifier get constructorName => _constructorName; |
| 10660 | 9274 |
| 10661 /** | 9275 @override |
| 10662 * Set the name of the constructor that is being invoked to the given | |
| 10663 * [identifier]. | |
| 10664 */ | |
| 10665 void set constructorName(SimpleIdentifier identifier) { | 9276 void set constructorName(SimpleIdentifier identifier) { |
| 10666 _constructorName = _becomeParentOf(identifier); | 9277 _constructorName = _becomeParentOf(identifier); |
| 10667 } | 9278 } |
| 10668 | 9279 |
| 10669 @override | 9280 @override |
| 10670 Token get endToken => _argumentList.endToken; | 9281 Token get endToken => _argumentList.endToken; |
| 10671 | 9282 |
| 10672 @override | 9283 @override |
| 10673 accept(AstVisitor visitor) => visitor.visitSuperConstructorInvocation(this); | 9284 accept(AstVisitor visitor) => visitor.visitSuperConstructorInvocation(this); |
| 10674 | 9285 |
| 10675 @override | 9286 @override |
| 10676 void visitChildren(AstVisitor visitor) { | 9287 void visitChildren(AstVisitor visitor) { |
| 10677 _safelyVisitChild(_constructorName, visitor); | 9288 _safelyVisitChild(_constructorName, visitor); |
| 10678 _safelyVisitChild(_argumentList, visitor); | 9289 _safelyVisitChild(_argumentList, visitor); |
| 10679 } | 9290 } |
| 10680 } | 9291 } |
| 10681 | 9292 |
| 10682 /** | 9293 /** |
| 10683 * A super expression. | 9294 * A super expression. |
| 10684 * | 9295 * |
| 10685 * > superExpression ::= | 9296 * > superExpression ::= |
| 10686 * > 'super' | 9297 * > 'super' |
| 10687 */ | 9298 */ |
| 10688 class SuperExpression extends Expression { | 9299 class SuperExpressionImpl extends ExpressionImpl implements SuperExpression { |
| 10689 /** | 9300 /** |
| 10690 * The token representing the 'super' keyword. | 9301 * The token representing the 'super' keyword. |
| 10691 */ | 9302 */ |
| 10692 Token superKeyword; | 9303 Token superKeyword; |
| 10693 | 9304 |
| 10694 /** | 9305 /** |
| 10695 * Initialize a newly created super expression. | 9306 * Initialize a newly created super expression. |
| 10696 */ | 9307 */ |
| 10697 SuperExpression(this.superKeyword); | 9308 SuperExpressionImpl(this.superKeyword); |
| 10698 | 9309 |
| 10699 @override | 9310 @override |
| 10700 Token get beginToken => superKeyword; | 9311 Token get beginToken => superKeyword; |
| 10701 | 9312 |
| 10702 @override | 9313 @override |
| 10703 Iterable get childEntities => new ChildEntities()..add(superKeyword); | 9314 Iterable get childEntities => new ChildEntities()..add(superKeyword); |
| 10704 | 9315 |
| 10705 @override | 9316 @override |
| 10706 Token get endToken => superKeyword; | 9317 Token get endToken => superKeyword; |
| 10707 | 9318 |
| 10708 @override | 9319 @override |
| 10709 int get precedence => 16; | 9320 int get precedence => 16; |
| 10710 | 9321 |
| 10711 @override | 9322 @override |
| 10712 accept(AstVisitor visitor) => visitor.visitSuperExpression(this); | 9323 accept(AstVisitor visitor) => visitor.visitSuperExpression(this); |
| 10713 | 9324 |
| 10714 @override | 9325 @override |
| 10715 void visitChildren(AstVisitor visitor) { | 9326 void visitChildren(AstVisitor visitor) { |
| 10716 // There are no children to visit. | 9327 // There are no children to visit. |
| 10717 } | 9328 } |
| 10718 } | 9329 } |
| 10719 | 9330 |
| 10720 /** | 9331 /** |
| 10721 * A case in a switch statement. | 9332 * A case in a switch statement. |
| 10722 * | 9333 * |
| 10723 * > switchCase ::= | 9334 * > switchCase ::= |
| 10724 * > [SimpleIdentifier]* 'case' [Expression] ':' [Statement]* | 9335 * > [SimpleIdentifier]* 'case' [Expression] ':' [Statement]* |
| 10725 */ | 9336 */ |
| 10726 class SwitchCase extends SwitchMember { | 9337 class SwitchCaseImpl extends SwitchMemberImpl implements SwitchCase { |
| 10727 /** | 9338 /** |
| 10728 * The expression controlling whether the statements will be executed. | 9339 * The expression controlling whether the statements will be executed. |
| 10729 */ | 9340 */ |
| 10730 Expression _expression; | 9341 Expression _expression; |
| 10731 | 9342 |
| 10732 /** | 9343 /** |
| 10733 * Initialize a newly created switch case. The list of [labels] can be `null` | 9344 * Initialize a newly created switch case. The list of [labels] can be `null` |
| 10734 * if there are no labels. | 9345 * if there are no labels. |
| 10735 */ | 9346 */ |
| 10736 SwitchCase(List<Label> labels, Token keyword, Expression expression, | 9347 SwitchCaseImpl(List<Label> labels, Token keyword, Expression expression, |
| 10737 Token colon, List<Statement> statements) | 9348 Token colon, List<Statement> statements) |
| 10738 : super(labels, keyword, colon, statements) { | 9349 : super(labels, keyword, colon, statements) { |
| 10739 _expression = _becomeParentOf(expression); | 9350 _expression = _becomeParentOf(expression); |
| 10740 } | 9351 } |
| 10741 | 9352 |
| 10742 @override | 9353 @override |
| 10743 Iterable get childEntities => new ChildEntities() | 9354 Iterable get childEntities => new ChildEntities() |
| 10744 ..addAll(labels) | 9355 ..addAll(labels) |
| 10745 ..add(keyword) | 9356 ..add(keyword) |
| 10746 ..add(_expression) | 9357 ..add(_expression) |
| 10747 ..add(colon) | 9358 ..add(colon) |
| 10748 ..addAll(statements); | 9359 ..addAll(statements); |
| 10749 | 9360 |
| 10750 /** | 9361 @override |
| 10751 * Return the expression controlling whether the statements will be executed. | |
| 10752 */ | |
| 10753 Expression get expression => _expression; | 9362 Expression get expression => _expression; |
| 10754 | 9363 |
| 10755 /** | 9364 @override |
| 10756 * Set the expression controlling whether the statements will be executed to | |
| 10757 * the given [expression]. | |
| 10758 */ | |
| 10759 void set expression(Expression expression) { | 9365 void set expression(Expression expression) { |
| 10760 _expression = _becomeParentOf(expression); | 9366 _expression = _becomeParentOf(expression); |
| 10761 } | 9367 } |
| 10762 | 9368 |
| 10763 @override | 9369 @override |
| 10764 accept(AstVisitor visitor) => visitor.visitSwitchCase(this); | 9370 accept(AstVisitor visitor) => visitor.visitSwitchCase(this); |
| 10765 | 9371 |
| 10766 @override | 9372 @override |
| 10767 void visitChildren(AstVisitor visitor) { | 9373 void visitChildren(AstVisitor visitor) { |
| 10768 labels.accept(visitor); | 9374 labels.accept(visitor); |
| 10769 _safelyVisitChild(_expression, visitor); | 9375 _safelyVisitChild(_expression, visitor); |
| 10770 statements.accept(visitor); | 9376 statements.accept(visitor); |
| 10771 } | 9377 } |
| 10772 } | 9378 } |
| 10773 | 9379 |
| 10774 /** | 9380 /** |
| 10775 * The default case in a switch statement. | 9381 * The default case in a switch statement. |
| 10776 * | 9382 * |
| 10777 * > switchDefault ::= | 9383 * > switchDefault ::= |
| 10778 * > [SimpleIdentifier]* 'default' ':' [Statement]* | 9384 * > [SimpleIdentifier]* 'default' ':' [Statement]* |
| 10779 */ | 9385 */ |
| 10780 class SwitchDefault extends SwitchMember { | 9386 class SwitchDefaultImpl extends SwitchMemberImpl implements SwitchDefault { |
| 10781 /** | 9387 /** |
| 10782 * Initialize a newly created switch default. The list of [labels] can be | 9388 * Initialize a newly created switch default. The list of [labels] can be |
| 10783 * `null` if there are no labels. | 9389 * `null` if there are no labels. |
| 10784 */ | 9390 */ |
| 10785 SwitchDefault(List<Label> labels, Token keyword, Token colon, | 9391 SwitchDefaultImpl(List<Label> labels, Token keyword, Token colon, |
| 10786 List<Statement> statements) | 9392 List<Statement> statements) |
| 10787 : super(labels, keyword, colon, statements); | 9393 : super(labels, keyword, colon, statements); |
| 10788 | 9394 |
| 10789 @override | 9395 @override |
| 10790 Iterable get childEntities => new ChildEntities() | 9396 Iterable get childEntities => new ChildEntities() |
| 10791 ..addAll(labels) | 9397 ..addAll(labels) |
| 10792 ..add(keyword) | 9398 ..add(keyword) |
| 10793 ..add(colon) | 9399 ..add(colon) |
| 10794 ..addAll(statements); | 9400 ..addAll(statements); |
| 10795 | 9401 |
| 10796 @override | 9402 @override |
| 10797 accept(AstVisitor visitor) => visitor.visitSwitchDefault(this); | 9403 accept(AstVisitor visitor) => visitor.visitSwitchDefault(this); |
| 10798 | 9404 |
| 10799 @override | 9405 @override |
| 10800 void visitChildren(AstVisitor visitor) { | 9406 void visitChildren(AstVisitor visitor) { |
| 10801 labels.accept(visitor); | 9407 labels.accept(visitor); |
| 10802 statements.accept(visitor); | 9408 statements.accept(visitor); |
| 10803 } | 9409 } |
| 10804 } | 9410 } |
| 10805 | 9411 |
| 10806 /** | 9412 /** |
| 10807 * An element within a switch statement. | 9413 * An element within a switch statement. |
| 10808 * | 9414 * |
| 10809 * > switchMember ::= | 9415 * > switchMember ::= |
| 10810 * > switchCase | 9416 * > switchCase |
| 10811 * > | switchDefault | 9417 * > | switchDefault |
| 10812 */ | 9418 */ |
| 10813 abstract class SwitchMember extends AstNode { | 9419 abstract class SwitchMemberImpl extends AstNodeImpl implements SwitchMember { |
| 10814 /** | 9420 /** |
| 10815 * The labels associated with the switch member. | 9421 * The labels associated with the switch member. |
| 10816 */ | 9422 */ |
| 10817 NodeList<Label> _labels; | 9423 NodeList<Label> _labels; |
| 10818 | 9424 |
| 10819 /** | 9425 /** |
| 10820 * The token representing the 'case' or 'default' keyword. | 9426 * The token representing the 'case' or 'default' keyword. |
| 10821 */ | 9427 */ |
| 10822 Token keyword; | 9428 Token keyword; |
| 10823 | 9429 |
| 10824 /** | 9430 /** |
| 10825 * The colon separating the keyword or the expression from the statements. | 9431 * The colon separating the keyword or the expression from the statements. |
| 10826 */ | 9432 */ |
| 10827 Token colon; | 9433 Token colon; |
| 10828 | 9434 |
| 10829 /** | 9435 /** |
| 10830 * The statements that will be executed if this switch member is selected. | 9436 * The statements that will be executed if this switch member is selected. |
| 10831 */ | 9437 */ |
| 10832 NodeList<Statement> _statements; | 9438 NodeList<Statement> _statements; |
| 10833 | 9439 |
| 10834 /** | 9440 /** |
| 10835 * Initialize a newly created switch member. The list of [labels] can be | 9441 * Initialize a newly created switch member. The list of [labels] can be |
| 10836 * `null` if there are no labels. | 9442 * `null` if there are no labels. |
| 10837 */ | 9443 */ |
| 10838 SwitchMember(List<Label> labels, this.keyword, this.colon, | 9444 SwitchMemberImpl(List<Label> labels, this.keyword, this.colon, |
| 10839 List<Statement> statements) { | 9445 List<Statement> statements) { |
| 10840 _labels = new NodeList<Label>(this, labels); | 9446 _labels = new NodeList<Label>(this, labels); |
| 10841 _statements = new NodeList<Statement>(this, statements); | 9447 _statements = new NodeList<Statement>(this, statements); |
| 10842 } | 9448 } |
| 10843 | 9449 |
| 10844 @override | 9450 @override |
| 10845 Token get beginToken { | 9451 Token get beginToken { |
| 10846 if (!_labels.isEmpty) { | 9452 if (!_labels.isEmpty) { |
| 10847 return _labels.beginToken; | 9453 return _labels.beginToken; |
| 10848 } | 9454 } |
| 10849 return keyword; | 9455 return keyword; |
| 10850 } | 9456 } |
| 10851 | 9457 |
| 10852 @override | 9458 @override |
| 10853 Token get endToken { | 9459 Token get endToken { |
| 10854 if (!_statements.isEmpty) { | 9460 if (!_statements.isEmpty) { |
| 10855 return _statements.endToken; | 9461 return _statements.endToken; |
| 10856 } | 9462 } |
| 10857 return colon; | 9463 return colon; |
| 10858 } | 9464 } |
| 10859 | 9465 |
| 10860 /** | 9466 @override |
| 10861 * Return the labels associated with the switch member. | |
| 10862 */ | |
| 10863 NodeList<Label> get labels => _labels; | 9467 NodeList<Label> get labels => _labels; |
| 10864 | 9468 |
| 10865 /** | 9469 @override |
| 10866 * Return the statements that will be executed if this switch member is | |
| 10867 * selected. | |
| 10868 */ | |
| 10869 NodeList<Statement> get statements => _statements; | 9470 NodeList<Statement> get statements => _statements; |
| 10870 } | 9471 } |
| 10871 | 9472 |
| 10872 /** | 9473 /** |
| 10873 * A switch statement. | 9474 * A switch statement. |
| 10874 * | 9475 * |
| 10875 * > switchStatement ::= | 9476 * > switchStatement ::= |
| 10876 * > 'switch' '(' [Expression] ')' '{' [SwitchCase]* [SwitchDefault]? '}' | 9477 * > 'switch' '(' [Expression] ')' '{' [SwitchCase]* [SwitchDefault]? '}' |
| 10877 */ | 9478 */ |
| 10878 class SwitchStatement extends Statement { | 9479 class SwitchStatementImpl extends StatementImpl implements SwitchStatement { |
| 10879 /** | 9480 /** |
| 10880 * The token representing the 'switch' keyword. | 9481 * The token representing the 'switch' keyword. |
| 10881 */ | 9482 */ |
| 10882 Token switchKeyword; | 9483 Token switchKeyword; |
| 10883 | 9484 |
| 10884 /** | 9485 /** |
| 10885 * The left parenthesis. | 9486 * The left parenthesis. |
| 10886 */ | 9487 */ |
| 10887 Token leftParenthesis; | 9488 Token leftParenthesis; |
| 10888 | 9489 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10909 | 9510 |
| 10910 /** | 9511 /** |
| 10911 * The right curly bracket. | 9512 * The right curly bracket. |
| 10912 */ | 9513 */ |
| 10913 Token rightBracket; | 9514 Token rightBracket; |
| 10914 | 9515 |
| 10915 /** | 9516 /** |
| 10916 * Initialize a newly created switch statement. The list of [members] can be | 9517 * Initialize a newly created switch statement. The list of [members] can be |
| 10917 * `null` if there are no switch members. | 9518 * `null` if there are no switch members. |
| 10918 */ | 9519 */ |
| 10919 SwitchStatement( | 9520 SwitchStatementImpl( |
| 10920 this.switchKeyword, | 9521 this.switchKeyword, |
| 10921 this.leftParenthesis, | 9522 this.leftParenthesis, |
| 10922 Expression expression, | 9523 Expression expression, |
| 10923 this.rightParenthesis, | 9524 this.rightParenthesis, |
| 10924 this.leftBracket, | 9525 this.leftBracket, |
| 10925 List<SwitchMember> members, | 9526 List<SwitchMember> members, |
| 10926 this.rightBracket) { | 9527 this.rightBracket) { |
| 10927 _expression = _becomeParentOf(expression); | 9528 _expression = _becomeParentOf(expression); |
| 10928 _members = new NodeList<SwitchMember>(this, members); | 9529 _members = new NodeList<SwitchMember>(this, members); |
| 10929 } | 9530 } |
| 10930 | 9531 |
| 10931 @override | 9532 @override |
| 10932 Token get beginToken => switchKeyword; | 9533 Token get beginToken => switchKeyword; |
| 10933 | 9534 |
| 10934 @override | 9535 @override |
| 10935 Iterable get childEntities => new ChildEntities() | 9536 Iterable get childEntities => new ChildEntities() |
| 10936 ..add(switchKeyword) | 9537 ..add(switchKeyword) |
| 10937 ..add(leftParenthesis) | 9538 ..add(leftParenthesis) |
| 10938 ..add(_expression) | 9539 ..add(_expression) |
| 10939 ..add(rightParenthesis) | 9540 ..add(rightParenthesis) |
| 10940 ..add(leftBracket) | 9541 ..add(leftBracket) |
| 10941 ..addAll(_members) | 9542 ..addAll(_members) |
| 10942 ..add(rightBracket); | 9543 ..add(rightBracket); |
| 10943 | 9544 |
| 10944 @override | 9545 @override |
| 10945 Token get endToken => rightBracket; | 9546 Token get endToken => rightBracket; |
| 10946 | 9547 |
| 10947 /** | 9548 @override |
| 10948 * Return the expression used to determine which of the switch members will be | |
| 10949 * selected. | |
| 10950 */ | |
| 10951 Expression get expression => _expression; | 9549 Expression get expression => _expression; |
| 10952 | 9550 |
| 10953 /** | 9551 @override |
| 10954 * Set the expression used to determine which of the switch members will be | |
| 10955 * selected to the given [expression]. | |
| 10956 */ | |
| 10957 void set expression(Expression expression) { | 9552 void set expression(Expression expression) { |
| 10958 _expression = _becomeParentOf(expression); | 9553 _expression = _becomeParentOf(expression); |
| 10959 } | 9554 } |
| 10960 | 9555 |
| 10961 /** | 9556 @override |
| 10962 * Return the switch members that can be selected by the expression. | |
| 10963 */ | |
| 10964 NodeList<SwitchMember> get members => _members; | 9557 NodeList<SwitchMember> get members => _members; |
| 10965 | 9558 |
| 10966 @override | 9559 @override |
| 10967 accept(AstVisitor visitor) => visitor.visitSwitchStatement(this); | 9560 accept(AstVisitor visitor) => visitor.visitSwitchStatement(this); |
| 10968 | 9561 |
| 10969 @override | 9562 @override |
| 10970 void visitChildren(AstVisitor visitor) { | 9563 void visitChildren(AstVisitor visitor) { |
| 10971 _safelyVisitChild(_expression, visitor); | 9564 _safelyVisitChild(_expression, visitor); |
| 10972 _members.accept(visitor); | 9565 _members.accept(visitor); |
| 10973 } | 9566 } |
| 10974 } | 9567 } |
| 10975 | 9568 |
| 10976 /** | 9569 /** |
| 10977 * A symbol literal expression. | 9570 * A symbol literal expression. |
| 10978 * | 9571 * |
| 10979 * > symbolLiteral ::= | 9572 * > symbolLiteral ::= |
| 10980 * > '#' (operator | (identifier ('.' identifier)*)) | 9573 * > '#' (operator | (identifier ('.' identifier)*)) |
| 10981 */ | 9574 */ |
| 10982 class SymbolLiteral extends Literal { | 9575 class SymbolLiteralImpl extends LiteralImpl implements SymbolLiteral { |
| 10983 /** | 9576 /** |
| 10984 * The token introducing the literal. | 9577 * The token introducing the literal. |
| 10985 */ | 9578 */ |
| 10986 Token poundSign; | 9579 Token poundSign; |
| 10987 | 9580 |
| 10988 /** | 9581 /** |
| 10989 * The components of the literal. | 9582 * The components of the literal. |
| 10990 */ | 9583 */ |
| 10991 final List<Token> components; | 9584 final List<Token> components; |
| 10992 | 9585 |
| 10993 /** | 9586 /** |
| 10994 * Initialize a newly created symbol literal. | 9587 * Initialize a newly created symbol literal. |
| 10995 */ | 9588 */ |
| 10996 SymbolLiteral(this.poundSign, this.components); | 9589 SymbolLiteralImpl(this.poundSign, this.components); |
| 10997 | 9590 |
| 10998 @override | 9591 @override |
| 10999 Token get beginToken => poundSign; | 9592 Token get beginToken => poundSign; |
| 11000 | 9593 |
| 11001 @override | 9594 @override |
| 11002 // TODO(paulberry): add "." tokens. | 9595 // TODO(paulberry): add "." tokens. |
| 11003 Iterable get childEntities => new ChildEntities() | 9596 Iterable get childEntities => new ChildEntities() |
| 11004 ..add(poundSign) | 9597 ..add(poundSign) |
| 11005 ..addAll(components); | 9598 ..addAll(components); |
| 11006 | 9599 |
| 11007 @override | 9600 @override |
| 11008 Token get endToken => components[components.length - 1]; | 9601 Token get endToken => components[components.length - 1]; |
| 11009 | 9602 |
| 11010 @override | 9603 @override |
| 11011 accept(AstVisitor visitor) => visitor.visitSymbolLiteral(this); | 9604 accept(AstVisitor visitor) => visitor.visitSymbolLiteral(this); |
| 11012 | 9605 |
| 11013 @override | 9606 @override |
| 11014 void visitChildren(AstVisitor visitor) { | 9607 void visitChildren(AstVisitor visitor) { |
| 11015 // There are no children to visit. | 9608 // There are no children to visit. |
| 11016 } | 9609 } |
| 11017 } | 9610 } |
| 11018 | 9611 |
| 11019 /** | 9612 /** |
| 11020 * A this expression. | 9613 * A this expression. |
| 11021 * | 9614 * |
| 11022 * > thisExpression ::= | 9615 * > thisExpression ::= |
| 11023 * > 'this' | 9616 * > 'this' |
| 11024 */ | 9617 */ |
| 11025 class ThisExpression extends Expression { | 9618 class ThisExpressionImpl extends ExpressionImpl implements ThisExpression { |
| 11026 /** | 9619 /** |
| 11027 * The token representing the 'this' keyword. | 9620 * The token representing the 'this' keyword. |
| 11028 */ | 9621 */ |
| 11029 Token thisKeyword; | 9622 Token thisKeyword; |
| 11030 | 9623 |
| 11031 /** | 9624 /** |
| 11032 * Initialize a newly created this expression. | 9625 * Initialize a newly created this expression. |
| 11033 */ | 9626 */ |
| 11034 ThisExpression(this.thisKeyword); | 9627 ThisExpressionImpl(this.thisKeyword); |
| 11035 | 9628 |
| 11036 @override | 9629 @override |
| 11037 Token get beginToken => thisKeyword; | 9630 Token get beginToken => thisKeyword; |
| 11038 | 9631 |
| 11039 @override | 9632 @override |
| 11040 Iterable get childEntities => new ChildEntities()..add(thisKeyword); | 9633 Iterable get childEntities => new ChildEntities()..add(thisKeyword); |
| 11041 | 9634 |
| 11042 @override | 9635 @override |
| 11043 Token get endToken => thisKeyword; | 9636 Token get endToken => thisKeyword; |
| 11044 | 9637 |
| 11045 @override | 9638 @override |
| 11046 int get precedence => 16; | 9639 int get precedence => 16; |
| 11047 | 9640 |
| 11048 @override | 9641 @override |
| 11049 accept(AstVisitor visitor) => visitor.visitThisExpression(this); | 9642 accept(AstVisitor visitor) => visitor.visitThisExpression(this); |
| 11050 | 9643 |
| 11051 @override | 9644 @override |
| 11052 void visitChildren(AstVisitor visitor) { | 9645 void visitChildren(AstVisitor visitor) { |
| 11053 // There are no children to visit. | 9646 // There are no children to visit. |
| 11054 } | 9647 } |
| 11055 } | 9648 } |
| 11056 | 9649 |
| 11057 /** | 9650 /** |
| 11058 * A throw expression. | 9651 * A throw expression. |
| 11059 * | 9652 * |
| 11060 * > throwExpression ::= | 9653 * > throwExpression ::= |
| 11061 * > 'throw' [Expression] | 9654 * > 'throw' [Expression] |
| 11062 */ | 9655 */ |
| 11063 class ThrowExpression extends Expression { | 9656 class ThrowExpressionImpl extends ExpressionImpl implements ThrowExpression { |
| 11064 /** | 9657 /** |
| 11065 * The token representing the 'throw' keyword. | 9658 * The token representing the 'throw' keyword. |
| 11066 */ | 9659 */ |
| 11067 Token throwKeyword; | 9660 Token throwKeyword; |
| 11068 | 9661 |
| 11069 /** | 9662 /** |
| 11070 * The expression computing the exception to be thrown. | 9663 * The expression computing the exception to be thrown. |
| 11071 */ | 9664 */ |
| 11072 Expression _expression; | 9665 Expression _expression; |
| 11073 | 9666 |
| 11074 /** | 9667 /** |
| 11075 * Initialize a newly created throw expression. | 9668 * Initialize a newly created throw expression. |
| 11076 */ | 9669 */ |
| 11077 ThrowExpression(this.throwKeyword, Expression expression) { | 9670 ThrowExpressionImpl(this.throwKeyword, Expression expression) { |
| 11078 _expression = _becomeParentOf(expression); | 9671 _expression = _becomeParentOf(expression); |
| 11079 } | 9672 } |
| 11080 | 9673 |
| 11081 @override | 9674 @override |
| 11082 Token get beginToken => throwKeyword; | 9675 Token get beginToken => throwKeyword; |
| 11083 | 9676 |
| 11084 @override | 9677 @override |
| 11085 Iterable get childEntities => | 9678 Iterable get childEntities => |
| 11086 new ChildEntities()..add(throwKeyword)..add(_expression); | 9679 new ChildEntities()..add(throwKeyword)..add(_expression); |
| 11087 | 9680 |
| 11088 @override | 9681 @override |
| 11089 Token get endToken { | 9682 Token get endToken { |
| 11090 if (_expression != null) { | 9683 if (_expression != null) { |
| 11091 return _expression.endToken; | 9684 return _expression.endToken; |
| 11092 } | 9685 } |
| 11093 return throwKeyword; | 9686 return throwKeyword; |
| 11094 } | 9687 } |
| 11095 | 9688 |
| 11096 /** | 9689 @override |
| 11097 * Return the expression computing the exception to be thrown. | |
| 11098 */ | |
| 11099 Expression get expression => _expression; | 9690 Expression get expression => _expression; |
| 11100 | 9691 |
| 11101 /** | 9692 @override |
| 11102 * Set the expression computing the exception to be thrown to the given | |
| 11103 * [expression]. | |
| 11104 */ | |
| 11105 void set expression(Expression expression) { | 9693 void set expression(Expression expression) { |
| 11106 _expression = _becomeParentOf(expression); | 9694 _expression = _becomeParentOf(expression); |
| 11107 } | 9695 } |
| 11108 | 9696 |
| 11109 @override | 9697 @override |
| 11110 int get precedence => 0; | 9698 int get precedence => 0; |
| 11111 | 9699 |
| 11112 @override | 9700 @override |
| 11113 accept(AstVisitor visitor) => visitor.visitThrowExpression(this); | 9701 accept(AstVisitor visitor) => visitor.visitThrowExpression(this); |
| 11114 | 9702 |
| 11115 @override | 9703 @override |
| 11116 void visitChildren(AstVisitor visitor) { | 9704 void visitChildren(AstVisitor visitor) { |
| 11117 _safelyVisitChild(_expression, visitor); | 9705 _safelyVisitChild(_expression, visitor); |
| 11118 } | 9706 } |
| 11119 } | 9707 } |
| 11120 | 9708 |
| 11121 /** | 9709 /** |
| 11122 * The declaration of one or more top-level variables of the same type. | 9710 * The declaration of one or more top-level variables of the same type. |
| 11123 * | 9711 * |
| 11124 * > topLevelVariableDeclaration ::= | 9712 * > topLevelVariableDeclaration ::= |
| 11125 * > ('final' | 'const') type? staticFinalDeclarationList ';' | 9713 * > ('final' | 'const') type? staticFinalDeclarationList ';' |
| 11126 * > | variableDeclaration ';' | 9714 * > | variableDeclaration ';' |
| 11127 */ | 9715 */ |
| 11128 class TopLevelVariableDeclaration extends CompilationUnitMember { | 9716 class TopLevelVariableDeclarationImpl extends CompilationUnitMemberImpl |
| 9717 implements TopLevelVariableDeclaration { |
| 11129 /** | 9718 /** |
| 11130 * The top-level variables being declared. | 9719 * The top-level variables being declared. |
| 11131 */ | 9720 */ |
| 11132 VariableDeclarationList _variableList; | 9721 VariableDeclarationList _variableList; |
| 11133 | 9722 |
| 11134 /** | 9723 /** |
| 11135 * The semicolon terminating the declaration. | 9724 * The semicolon terminating the declaration. |
| 11136 */ | 9725 */ |
| 11137 Token semicolon; | 9726 Token semicolon; |
| 11138 | 9727 |
| 11139 /** | 9728 /** |
| 11140 * Initialize a newly created top-level variable declaration. Either or both | 9729 * Initialize a newly created top-level variable declaration. Either or both |
| 11141 * of the [comment] and [metadata] can be `null` if the variable does not have | 9730 * of the [comment] and [metadata] can be `null` if the variable does not have |
| 11142 * the corresponding attribute. | 9731 * the corresponding attribute. |
| 11143 */ | 9732 */ |
| 11144 TopLevelVariableDeclaration(Comment comment, List<Annotation> metadata, | 9733 TopLevelVariableDeclarationImpl(Comment comment, List<Annotation> metadata, |
| 11145 VariableDeclarationList variableList, this.semicolon) | 9734 VariableDeclarationList variableList, this.semicolon) |
| 11146 : super(comment, metadata) { | 9735 : super(comment, metadata) { |
| 11147 _variableList = _becomeParentOf(variableList); | 9736 _variableList = _becomeParentOf(variableList); |
| 11148 } | 9737 } |
| 11149 | 9738 |
| 11150 @override | 9739 @override |
| 11151 Iterable get childEntities => | 9740 Iterable get childEntities => |
| 11152 super._childEntities..add(_variableList)..add(semicolon); | 9741 super._childEntities..add(_variableList)..add(semicolon); |
| 11153 | 9742 |
| 11154 @override | 9743 @override |
| 11155 Element get element => null; | 9744 Element get element => null; |
| 11156 | 9745 |
| 11157 @override | 9746 @override |
| 11158 Token get endToken => semicolon; | 9747 Token get endToken => semicolon; |
| 11159 | 9748 |
| 11160 @override | 9749 @override |
| 11161 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken; | 9750 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken; |
| 11162 | 9751 |
| 11163 /** | 9752 @override |
| 11164 * Return the top-level variables being declared. | |
| 11165 */ | |
| 11166 VariableDeclarationList get variables => _variableList; | 9753 VariableDeclarationList get variables => _variableList; |
| 11167 | 9754 |
| 11168 /** | 9755 @override |
| 11169 * Set the top-level variables being declared to the given list of | |
| 11170 * [variables]. | |
| 11171 */ | |
| 11172 void set variables(VariableDeclarationList variables) { | 9756 void set variables(VariableDeclarationList variables) { |
| 11173 _variableList = _becomeParentOf(variables); | 9757 _variableList = _becomeParentOf(variables); |
| 11174 } | 9758 } |
| 11175 | 9759 |
| 11176 @override | 9760 @override |
| 11177 accept(AstVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this); | 9761 accept(AstVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this); |
| 11178 | 9762 |
| 11179 @override | 9763 @override |
| 11180 void visitChildren(AstVisitor visitor) { | 9764 void visitChildren(AstVisitor visitor) { |
| 11181 super.visitChildren(visitor); | 9765 super.visitChildren(visitor); |
| 11182 _safelyVisitChild(_variableList, visitor); | 9766 _safelyVisitChild(_variableList, visitor); |
| 11183 } | 9767 } |
| 11184 } | 9768 } |
| 11185 | 9769 |
| 11186 /** | 9770 /** |
| 11187 * A try statement. | 9771 * A try statement. |
| 11188 * | 9772 * |
| 11189 * > tryStatement ::= | 9773 * > tryStatement ::= |
| 11190 * > 'try' [Block] ([CatchClause]+ finallyClause? | finallyClause) | 9774 * > 'try' [Block] ([CatchClause]+ finallyClause? | finallyClause) |
| 11191 * > | 9775 * > |
| 11192 * > finallyClause ::= | 9776 * > finallyClause ::= |
| 11193 * > 'finally' [Block] | 9777 * > 'finally' [Block] |
| 11194 */ | 9778 */ |
| 11195 class TryStatement extends Statement { | 9779 class TryStatementImpl extends StatementImpl implements TryStatement { |
| 11196 /** | 9780 /** |
| 11197 * The token representing the 'try' keyword. | 9781 * The token representing the 'try' keyword. |
| 11198 */ | 9782 */ |
| 11199 Token tryKeyword; | 9783 Token tryKeyword; |
| 11200 | 9784 |
| 11201 /** | 9785 /** |
| 11202 * The body of the statement. | 9786 * The body of the statement. |
| 11203 */ | 9787 */ |
| 11204 Block _body; | 9788 Block _body; |
| 11205 | 9789 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 11218 * The finally block contained in the try statement, or `null` if the | 9802 * The finally block contained in the try statement, or `null` if the |
| 11219 * statement does not contain a finally clause. | 9803 * statement does not contain a finally clause. |
| 11220 */ | 9804 */ |
| 11221 Block _finallyBlock; | 9805 Block _finallyBlock; |
| 11222 | 9806 |
| 11223 /** | 9807 /** |
| 11224 * Initialize a newly created try statement. The list of [catchClauses] can be | 9808 * Initialize a newly created try statement. The list of [catchClauses] can be |
| 11225 * `null` if there are no catch clauses. The [finallyKeyword] and | 9809 * `null` if there are no catch clauses. The [finallyKeyword] and |
| 11226 * [finallyBlock] can be `null` if there is no finally clause. | 9810 * [finallyBlock] can be `null` if there is no finally clause. |
| 11227 */ | 9811 */ |
| 11228 TryStatement(this.tryKeyword, Block body, List<CatchClause> catchClauses, | 9812 TryStatementImpl(this.tryKeyword, Block body, List<CatchClause> catchClauses, |
| 11229 this.finallyKeyword, Block finallyBlock) { | 9813 this.finallyKeyword, Block finallyBlock) { |
| 11230 _body = _becomeParentOf(body); | 9814 _body = _becomeParentOf(body); |
| 11231 _catchClauses = new NodeList<CatchClause>(this, catchClauses); | 9815 _catchClauses = new NodeList<CatchClause>(this, catchClauses); |
| 11232 _finallyBlock = _becomeParentOf(finallyBlock); | 9816 _finallyBlock = _becomeParentOf(finallyBlock); |
| 11233 } | 9817 } |
| 11234 | 9818 |
| 11235 @override | 9819 @override |
| 11236 Token get beginToken => tryKeyword; | 9820 Token get beginToken => tryKeyword; |
| 11237 | 9821 |
| 11238 /** | 9822 @override |
| 11239 * Return the body of the statement. | |
| 11240 */ | |
| 11241 Block get body => _body; | 9823 Block get body => _body; |
| 11242 | 9824 |
| 11243 /** | 9825 @override |
| 11244 * Set the body of the statement to the given [block]. | |
| 11245 */ | |
| 11246 void set body(Block block) { | 9826 void set body(Block block) { |
| 11247 _body = _becomeParentOf(block); | 9827 _body = _becomeParentOf(block); |
| 11248 } | 9828 } |
| 11249 | 9829 |
| 11250 /** | 9830 @override |
| 11251 * Return the catch clauses contained in the try statement. | |
| 11252 */ | |
| 11253 NodeList<CatchClause> get catchClauses => _catchClauses; | 9831 NodeList<CatchClause> get catchClauses => _catchClauses; |
| 11254 | 9832 |
| 11255 @override | 9833 @override |
| 11256 Iterable get childEntities => new ChildEntities() | 9834 Iterable get childEntities => new ChildEntities() |
| 11257 ..add(tryKeyword) | 9835 ..add(tryKeyword) |
| 11258 ..add(_body) | 9836 ..add(_body) |
| 11259 ..addAll(_catchClauses) | 9837 ..addAll(_catchClauses) |
| 11260 ..add(finallyKeyword) | 9838 ..add(finallyKeyword) |
| 11261 ..add(_finallyBlock); | 9839 ..add(_finallyBlock); |
| 11262 | 9840 |
| 11263 @override | 9841 @override |
| 11264 Token get endToken { | 9842 Token get endToken { |
| 11265 if (_finallyBlock != null) { | 9843 if (_finallyBlock != null) { |
| 11266 return _finallyBlock.endToken; | 9844 return _finallyBlock.endToken; |
| 11267 } else if (finallyKeyword != null) { | 9845 } else if (finallyKeyword != null) { |
| 11268 return finallyKeyword; | 9846 return finallyKeyword; |
| 11269 } else if (!_catchClauses.isEmpty) { | 9847 } else if (!_catchClauses.isEmpty) { |
| 11270 return _catchClauses.endToken; | 9848 return _catchClauses.endToken; |
| 11271 } | 9849 } |
| 11272 return _body.endToken; | 9850 return _body.endToken; |
| 11273 } | 9851 } |
| 11274 | 9852 |
| 11275 /** | 9853 @override |
| 11276 * Return the finally block contained in the try statement, or `null` if the | |
| 11277 * statement does not contain a finally clause. | |
| 11278 */ | |
| 11279 Block get finallyBlock => _finallyBlock; | 9854 Block get finallyBlock => _finallyBlock; |
| 11280 | 9855 |
| 11281 /** | 9856 @override |
| 11282 * Set the finally block contained in the try statement to the given [block]. | |
| 11283 */ | |
| 11284 void set finallyBlock(Block block) { | 9857 void set finallyBlock(Block block) { |
| 11285 _finallyBlock = _becomeParentOf(block); | 9858 _finallyBlock = _becomeParentOf(block); |
| 11286 } | 9859 } |
| 11287 | 9860 |
| 11288 @override | 9861 @override |
| 11289 accept(AstVisitor visitor) => visitor.visitTryStatement(this); | 9862 accept(AstVisitor visitor) => visitor.visitTryStatement(this); |
| 11290 | 9863 |
| 11291 @override | 9864 @override |
| 11292 void visitChildren(AstVisitor visitor) { | 9865 void visitChildren(AstVisitor visitor) { |
| 11293 _safelyVisitChild(_body, visitor); | 9866 _safelyVisitChild(_body, visitor); |
| 11294 _catchClauses.accept(visitor); | 9867 _catchClauses.accept(visitor); |
| 11295 _safelyVisitChild(_finallyBlock, visitor); | 9868 _safelyVisitChild(_finallyBlock, visitor); |
| 11296 } | 9869 } |
| 11297 } | 9870 } |
| 11298 | 9871 |
| 11299 /** | 9872 /** |
| 11300 * The declaration of a type alias. | 9873 * The declaration of a type alias. |
| 11301 * | 9874 * |
| 11302 * > typeAlias ::= | 9875 * > typeAlias ::= |
| 11303 * > 'typedef' typeAliasBody | 9876 * > 'typedef' typeAliasBody |
| 11304 * > | 9877 * > |
| 11305 * > typeAliasBody ::= | 9878 * > typeAliasBody ::= |
| 11306 * > classTypeAlias | 9879 * > classTypeAlias |
| 11307 * > | functionTypeAlias | 9880 * > | functionTypeAlias |
| 11308 */ | 9881 */ |
| 11309 abstract class TypeAlias extends NamedCompilationUnitMember { | 9882 abstract class TypeAliasImpl extends NamedCompilationUnitMemberImpl |
| 9883 implements TypeAlias { |
| 11310 /** | 9884 /** |
| 11311 * The token representing the 'typedef' keyword. | 9885 * The token representing the 'typedef' keyword. |
| 11312 */ | 9886 */ |
| 11313 Token typedefKeyword; | 9887 Token typedefKeyword; |
| 11314 | 9888 |
| 11315 /** | 9889 /** |
| 11316 * The semicolon terminating the declaration. | 9890 * The semicolon terminating the declaration. |
| 11317 */ | 9891 */ |
| 11318 Token semicolon; | 9892 Token semicolon; |
| 11319 | 9893 |
| 11320 /** | 9894 /** |
| 11321 * Initialize a newly created type alias. Either or both of the [comment] and | 9895 * Initialize a newly created type alias. Either or both of the [comment] and |
| 11322 * [metadata] can be `null` if the declaration does not have the corresponding | 9896 * [metadata] can be `null` if the declaration does not have the corresponding |
| 11323 * attribute. | 9897 * attribute. |
| 11324 */ | 9898 */ |
| 11325 TypeAlias(Comment comment, List<Annotation> metadata, this.typedefKeyword, | 9899 TypeAliasImpl(Comment comment, List<Annotation> metadata, this.typedefKeyword, |
| 11326 SimpleIdentifier name, this.semicolon) | 9900 SimpleIdentifier name, this.semicolon) |
| 11327 : super(comment, metadata, name); | 9901 : super(comment, metadata, name); |
| 11328 | 9902 |
| 11329 @override | 9903 @override |
| 11330 Token get endToken => semicolon; | 9904 Token get endToken => semicolon; |
| 11331 | 9905 |
| 11332 @override | 9906 @override |
| 11333 Token get firstTokenAfterCommentAndMetadata => typedefKeyword; | 9907 Token get firstTokenAfterCommentAndMetadata => typedefKeyword; |
| 11334 } | 9908 } |
| 11335 | 9909 |
| 11336 /** | 9910 /** |
| 11337 * A list of type arguments. | 9911 * A list of type arguments. |
| 11338 * | 9912 * |
| 11339 * > typeArguments ::= | 9913 * > typeArguments ::= |
| 11340 * > '<' typeName (',' typeName)* '>' | 9914 * > '<' typeName (',' typeName)* '>' |
| 11341 */ | 9915 */ |
| 11342 class TypeArgumentList extends AstNode { | 9916 class TypeArgumentListImpl extends AstNodeImpl implements TypeArgumentList { |
| 11343 /** | 9917 /** |
| 11344 * The left bracket. | 9918 * The left bracket. |
| 11345 */ | 9919 */ |
| 11346 Token leftBracket; | 9920 Token leftBracket; |
| 11347 | 9921 |
| 11348 /** | 9922 /** |
| 11349 * The type arguments associated with the type. | 9923 * The type arguments associated with the type. |
| 11350 */ | 9924 */ |
| 11351 NodeList<TypeName> _arguments; | 9925 NodeList<TypeName> _arguments; |
| 11352 | 9926 |
| 11353 /** | 9927 /** |
| 11354 * The right bracket. | 9928 * The right bracket. |
| 11355 */ | 9929 */ |
| 11356 Token rightBracket; | 9930 Token rightBracket; |
| 11357 | 9931 |
| 11358 /** | 9932 /** |
| 11359 * Initialize a newly created list of type arguments. | 9933 * Initialize a newly created list of type arguments. |
| 11360 */ | 9934 */ |
| 11361 TypeArgumentList( | 9935 TypeArgumentListImpl( |
| 11362 this.leftBracket, List<TypeName> arguments, this.rightBracket) { | 9936 this.leftBracket, List<TypeName> arguments, this.rightBracket) { |
| 11363 _arguments = new NodeList<TypeName>(this, arguments); | 9937 _arguments = new NodeList<TypeName>(this, arguments); |
| 11364 } | 9938 } |
| 11365 | 9939 |
| 11366 /** | 9940 @override |
| 11367 * Return the type arguments associated with the type. | |
| 11368 */ | |
| 11369 NodeList<TypeName> get arguments => _arguments; | 9941 NodeList<TypeName> get arguments => _arguments; |
| 11370 | 9942 |
| 11371 @override | 9943 @override |
| 11372 Token get beginToken => leftBracket; | 9944 Token get beginToken => leftBracket; |
| 11373 | 9945 |
| 11374 @override | 9946 @override |
| 11375 // TODO(paulberry): Add commas. | 9947 // TODO(paulberry): Add commas. |
| 11376 Iterable get childEntities => new ChildEntities() | 9948 Iterable get childEntities => new ChildEntities() |
| 11377 ..add(leftBracket) | 9949 ..add(leftBracket) |
| 11378 ..addAll(_arguments) | 9950 ..addAll(_arguments) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 11390 } | 9962 } |
| 11391 } | 9963 } |
| 11392 | 9964 |
| 11393 /** | 9965 /** |
| 11394 * A literal that has a type associated with it. | 9966 * A literal that has a type associated with it. |
| 11395 * | 9967 * |
| 11396 * > typedLiteral ::= | 9968 * > typedLiteral ::= |
| 11397 * > [ListLiteral] | 9969 * > [ListLiteral] |
| 11398 * > | [MapLiteral] | 9970 * > | [MapLiteral] |
| 11399 */ | 9971 */ |
| 11400 abstract class TypedLiteral extends Literal { | 9972 abstract class TypedLiteralImpl extends LiteralImpl implements TypedLiteral { |
| 11401 /** | 9973 /** |
| 11402 * The token representing the 'const' keyword, or `null` if the literal is not | 9974 * The token representing the 'const' keyword, or `null` if the literal is not |
| 11403 * a constant. | 9975 * a constant. |
| 11404 */ | 9976 */ |
| 11405 Token constKeyword; | 9977 Token constKeyword; |
| 11406 | 9978 |
| 11407 /** | 9979 /** |
| 11408 * The type argument associated with this literal, or `null` if no type | 9980 * The type argument associated with this literal, or `null` if no type |
| 11409 * arguments were declared. | 9981 * arguments were declared. |
| 11410 */ | 9982 */ |
| 11411 TypeArgumentList _typeArguments; | 9983 TypeArgumentList _typeArguments; |
| 11412 | 9984 |
| 11413 /** | 9985 /** |
| 11414 * Initialize a newly created typed literal. The [constKeyword] can be `null`\ | 9986 * Initialize a newly created typed literal. The [constKeyword] can be `null`\ |
| 11415 * if the literal is not a constant. The [typeArguments] can be `null` if no | 9987 * if the literal is not a constant. The [typeArguments] can be `null` if no |
| 11416 * type arguments were declared. | 9988 * type arguments were declared. |
| 11417 */ | 9989 */ |
| 11418 TypedLiteral(this.constKeyword, TypeArgumentList typeArguments) { | 9990 TypedLiteralImpl(this.constKeyword, TypeArgumentList typeArguments) { |
| 11419 _typeArguments = _becomeParentOf(typeArguments); | 9991 _typeArguments = _becomeParentOf(typeArguments); |
| 11420 } | 9992 } |
| 11421 | 9993 |
| 11422 /** | 9994 @override |
| 11423 * Return the type argument associated with this literal, or `null` if no type | |
| 11424 * arguments were declared. | |
| 11425 */ | |
| 11426 TypeArgumentList get typeArguments => _typeArguments; | 9995 TypeArgumentList get typeArguments => _typeArguments; |
| 11427 | 9996 |
| 11428 /** | 9997 @override |
| 11429 * Set the type argument associated with this literal to the given | |
| 11430 * [typeArguments]. | |
| 11431 */ | |
| 11432 void set typeArguments(TypeArgumentList typeArguments) { | 9998 void set typeArguments(TypeArgumentList typeArguments) { |
| 11433 _typeArguments = _becomeParentOf(typeArguments); | 9999 _typeArguments = _becomeParentOf(typeArguments); |
| 11434 } | 10000 } |
| 11435 | 10001 |
| 11436 ChildEntities get _childEntities => | 10002 ChildEntities get _childEntities => |
| 11437 new ChildEntities()..add(constKeyword)..add(_typeArguments); | 10003 new ChildEntities()..add(constKeyword)..add(_typeArguments); |
| 11438 | 10004 |
| 11439 @override | 10005 @override |
| 11440 void visitChildren(AstVisitor visitor) { | 10006 void visitChildren(AstVisitor visitor) { |
| 11441 _safelyVisitChild(_typeArguments, visitor); | 10007 _safelyVisitChild(_typeArguments, visitor); |
| 11442 } | 10008 } |
| 11443 } | 10009 } |
| 11444 | 10010 |
| 11445 /** | 10011 /** |
| 11446 * The name of a type, which can optionally include type arguments. | 10012 * The name of a type, which can optionally include type arguments. |
| 11447 * | 10013 * |
| 11448 * > typeName ::= | 10014 * > typeName ::= |
| 11449 * > [Identifier] typeArguments? | 10015 * > [Identifier] typeArguments? |
| 11450 */ | 10016 */ |
| 11451 class TypeName extends AstNode { | 10017 class TypeNameImpl extends AstNodeImpl implements TypeName { |
| 11452 /** | 10018 /** |
| 11453 * The name of the type. | 10019 * The name of the type. |
| 11454 */ | 10020 */ |
| 11455 Identifier _name; | 10021 Identifier _name; |
| 11456 | 10022 |
| 11457 /** | 10023 /** |
| 11458 * The type arguments associated with the type, or `null` if there are no type | 10024 * The type arguments associated with the type, or `null` if there are no type |
| 11459 * arguments. | 10025 * arguments. |
| 11460 */ | 10026 */ |
| 11461 TypeArgumentList _typeArguments; | 10027 TypeArgumentList _typeArguments; |
| 11462 | 10028 |
| 11463 /** | 10029 /** |
| 11464 * The type being named, or `null` if the AST structure has not been resolved. | 10030 * The type being named, or `null` if the AST structure has not been resolved. |
| 11465 */ | 10031 */ |
| 11466 DartType type; | 10032 DartType type; |
| 11467 | 10033 |
| 11468 /** | 10034 /** |
| 11469 * Initialize a newly created type name. The [typeArguments] can be `null` if | 10035 * Initialize a newly created type name. The [typeArguments] can be `null` if |
| 11470 * there are no type arguments. | 10036 * there are no type arguments. |
| 11471 */ | 10037 */ |
| 11472 TypeName(Identifier name, TypeArgumentList typeArguments) { | 10038 TypeNameImpl(Identifier name, TypeArgumentList typeArguments) { |
| 11473 _name = _becomeParentOf(name); | 10039 _name = _becomeParentOf(name); |
| 11474 _typeArguments = _becomeParentOf(typeArguments); | 10040 _typeArguments = _becomeParentOf(typeArguments); |
| 11475 } | 10041 } |
| 11476 | 10042 |
| 11477 @override | 10043 @override |
| 11478 Token get beginToken => _name.beginToken; | 10044 Token get beginToken => _name.beginToken; |
| 11479 | 10045 |
| 11480 @override | 10046 @override |
| 11481 Iterable get childEntities => | 10047 Iterable get childEntities => |
| 11482 new ChildEntities()..add(_name)..add(_typeArguments); | 10048 new ChildEntities()..add(_name)..add(_typeArguments); |
| 11483 | 10049 |
| 11484 @override | 10050 @override |
| 11485 Token get endToken { | 10051 Token get endToken { |
| 11486 if (_typeArguments != null) { | 10052 if (_typeArguments != null) { |
| 11487 return _typeArguments.endToken; | 10053 return _typeArguments.endToken; |
| 11488 } | 10054 } |
| 11489 return _name.endToken; | 10055 return _name.endToken; |
| 11490 } | 10056 } |
| 11491 | 10057 |
| 11492 /** | 10058 @override |
| 11493 * Return `true` if this type is a deferred type. | |
| 11494 * | |
| 11495 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form | |
| 11496 * </i>p.T</i> where <i>p</i> is a deferred prefix. | |
| 11497 */ | |
| 11498 bool get isDeferred { | 10059 bool get isDeferred { |
| 11499 Identifier identifier = name; | 10060 Identifier identifier = name; |
| 11500 if (identifier is! PrefixedIdentifier) { | 10061 if (identifier is! PrefixedIdentifier) { |
| 11501 return false; | 10062 return false; |
| 11502 } | 10063 } |
| 11503 return (identifier as PrefixedIdentifier).isDeferred; | 10064 return (identifier as PrefixedIdentifier).isDeferred; |
| 11504 } | 10065 } |
| 11505 | 10066 |
| 11506 @override | 10067 @override |
| 11507 bool get isSynthetic => _name.isSynthetic && _typeArguments == null; | 10068 bool get isSynthetic => _name.isSynthetic && _typeArguments == null; |
| 11508 | 10069 |
| 11509 /** | 10070 @override |
| 11510 * Return the name of the type. | |
| 11511 */ | |
| 11512 Identifier get name => _name; | 10071 Identifier get name => _name; |
| 11513 | 10072 |
| 11514 /** | 10073 @override |
| 11515 * Set the name of the type to the given [identifier]. | |
| 11516 */ | |
| 11517 void set name(Identifier identifier) { | 10074 void set name(Identifier identifier) { |
| 11518 _name = _becomeParentOf(identifier); | 10075 _name = _becomeParentOf(identifier); |
| 11519 } | 10076 } |
| 11520 | 10077 |
| 11521 /** | 10078 @override |
| 11522 * Return the type arguments associated with the type, or `null` if there are | |
| 11523 * no type arguments. | |
| 11524 */ | |
| 11525 TypeArgumentList get typeArguments => _typeArguments; | 10079 TypeArgumentList get typeArguments => _typeArguments; |
| 11526 | 10080 |
| 11527 /** | 10081 @override |
| 11528 * Set the type arguments associated with the type to the given | |
| 11529 * [typeArguments]. | |
| 11530 */ | |
| 11531 void set typeArguments(TypeArgumentList typeArguments) { | 10082 void set typeArguments(TypeArgumentList typeArguments) { |
| 11532 _typeArguments = _becomeParentOf(typeArguments); | 10083 _typeArguments = _becomeParentOf(typeArguments); |
| 11533 } | 10084 } |
| 11534 | 10085 |
| 11535 @override | 10086 @override |
| 11536 accept(AstVisitor visitor) => visitor.visitTypeName(this); | 10087 accept(AstVisitor visitor) => visitor.visitTypeName(this); |
| 11537 | 10088 |
| 11538 @override | 10089 @override |
| 11539 void visitChildren(AstVisitor visitor) { | 10090 void visitChildren(AstVisitor visitor) { |
| 11540 _safelyVisitChild(_name, visitor); | 10091 _safelyVisitChild(_name, visitor); |
| 11541 _safelyVisitChild(_typeArguments, visitor); | 10092 _safelyVisitChild(_typeArguments, visitor); |
| 11542 } | 10093 } |
| 11543 } | 10094 } |
| 11544 | 10095 |
| 11545 /** | 10096 /** |
| 11546 * A type parameter. | 10097 * A type parameter. |
| 11547 * | 10098 * |
| 11548 * > typeParameter ::= | 10099 * > typeParameter ::= |
| 11549 * > [SimpleIdentifier] ('extends' [TypeName])? | 10100 * > [SimpleIdentifier] ('extends' [TypeName])? |
| 11550 */ | 10101 */ |
| 11551 class TypeParameter extends Declaration { | 10102 class TypeParameterImpl extends DeclarationImpl implements TypeParameter { |
| 11552 /** | 10103 /** |
| 11553 * The name of the type parameter. | 10104 * The name of the type parameter. |
| 11554 */ | 10105 */ |
| 11555 SimpleIdentifier _name; | 10106 SimpleIdentifier _name; |
| 11556 | 10107 |
| 11557 /** | 10108 /** |
| 11558 * The token representing the 'extends' keyword, or `null` if there is no | 10109 * The token representing the 'extends' keyword, or `null` if there is no |
| 11559 * explicit upper bound. | 10110 * explicit upper bound. |
| 11560 */ | 10111 */ |
| 11561 Token extendsKeyword; | 10112 Token extendsKeyword; |
| 11562 | 10113 |
| 11563 /** | 10114 /** |
| 11564 * The name of the upper bound for legal arguments, or `null` if there is no | 10115 * The name of the upper bound for legal arguments, or `null` if there is no |
| 11565 * explicit upper bound. | 10116 * explicit upper bound. |
| 11566 */ | 10117 */ |
| 11567 TypeName _bound; | 10118 TypeName _bound; |
| 11568 | 10119 |
| 11569 /** | 10120 /** |
| 11570 * Initialize a newly created type parameter. Either or both of the [comment] | 10121 * Initialize a newly created type parameter. Either or both of the [comment] |
| 11571 * and [metadata] can be `null` if the parameter does not have the | 10122 * and [metadata] can be `null` if the parameter does not have the |
| 11572 * corresponding attribute. The [extendsKeyword] and [bound] can be `null` if | 10123 * corresponding attribute. The [extendsKeyword] and [bound] can be `null` if |
| 11573 * the parameter does not have an upper bound. | 10124 * the parameter does not have an upper bound. |
| 11574 */ | 10125 */ |
| 11575 TypeParameter(Comment comment, List<Annotation> metadata, | 10126 TypeParameterImpl(Comment comment, List<Annotation> metadata, |
| 11576 SimpleIdentifier name, this.extendsKeyword, TypeName bound) | 10127 SimpleIdentifier name, this.extendsKeyword, TypeName bound) |
| 11577 : super(comment, metadata) { | 10128 : super(comment, metadata) { |
| 11578 _name = _becomeParentOf(name); | 10129 _name = _becomeParentOf(name); |
| 11579 _bound = _becomeParentOf(bound); | 10130 _bound = _becomeParentOf(bound); |
| 11580 } | 10131 } |
| 11581 | 10132 |
| 11582 /** | 10133 @override |
| 11583 * Return the name of the upper bound for legal arguments, or `null` if there | |
| 11584 * is no explicit upper bound. | |
| 11585 */ | |
| 11586 TypeName get bound => _bound; | 10134 TypeName get bound => _bound; |
| 11587 | 10135 |
| 11588 /** | 10136 @override |
| 11589 * Set the name of the upper bound for legal arguments to the given | |
| 11590 * [typeName]. | |
| 11591 */ | |
| 11592 void set bound(TypeName typeName) { | 10137 void set bound(TypeName typeName) { |
| 11593 _bound = _becomeParentOf(typeName); | 10138 _bound = _becomeParentOf(typeName); |
| 11594 } | 10139 } |
| 11595 | 10140 |
| 11596 @override | 10141 @override |
| 11597 Iterable get childEntities => | 10142 Iterable get childEntities => |
| 11598 super._childEntities..add(_name)..add(extendsKeyword)..add(_bound); | 10143 super._childEntities..add(_name)..add(extendsKeyword)..add(_bound); |
| 11599 | 10144 |
| 11600 @override | 10145 @override |
| 11601 TypeParameterElement get element => | 10146 TypeParameterElement get element => |
| 11602 _name != null ? (_name.staticElement as TypeParameterElement) : null; | 10147 _name != null ? (_name.staticElement as TypeParameterElement) : null; |
| 11603 | 10148 |
| 11604 @override | 10149 @override |
| 11605 Token get endToken { | 10150 Token get endToken { |
| 11606 if (_bound == null) { | 10151 if (_bound == null) { |
| 11607 return _name.endToken; | 10152 return _name.endToken; |
| 11608 } | 10153 } |
| 11609 return _bound.endToken; | 10154 return _bound.endToken; |
| 11610 } | 10155 } |
| 11611 | 10156 |
| 11612 @override | 10157 @override |
| 11613 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; | 10158 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; |
| 11614 | 10159 |
| 11615 /** | 10160 @override |
| 11616 * Return the name of the type parameter. | |
| 11617 */ | |
| 11618 SimpleIdentifier get name => _name; | 10161 SimpleIdentifier get name => _name; |
| 11619 | 10162 |
| 11620 /** | 10163 @override |
| 11621 * Set the name of the type parameter to the given [identifier]. | |
| 11622 */ | |
| 11623 void set name(SimpleIdentifier identifier) { | 10164 void set name(SimpleIdentifier identifier) { |
| 11624 _name = _becomeParentOf(identifier); | 10165 _name = _becomeParentOf(identifier); |
| 11625 } | 10166 } |
| 11626 | 10167 |
| 11627 @override | 10168 @override |
| 11628 accept(AstVisitor visitor) => visitor.visitTypeParameter(this); | 10169 accept(AstVisitor visitor) => visitor.visitTypeParameter(this); |
| 11629 | 10170 |
| 11630 @override | 10171 @override |
| 11631 void visitChildren(AstVisitor visitor) { | 10172 void visitChildren(AstVisitor visitor) { |
| 11632 super.visitChildren(visitor); | 10173 super.visitChildren(visitor); |
| 11633 _safelyVisitChild(_name, visitor); | 10174 _safelyVisitChild(_name, visitor); |
| 11634 _safelyVisitChild(_bound, visitor); | 10175 _safelyVisitChild(_bound, visitor); |
| 11635 } | 10176 } |
| 11636 } | 10177 } |
| 11637 | 10178 |
| 11638 /** | 10179 /** |
| 11639 * Type parameters within a declaration. | 10180 * Type parameters within a declaration. |
| 11640 * | 10181 * |
| 11641 * > typeParameterList ::= | 10182 * > typeParameterList ::= |
| 11642 * > '<' [TypeParameter] (',' [TypeParameter])* '>' | 10183 * > '<' [TypeParameter] (',' [TypeParameter])* '>' |
| 11643 */ | 10184 */ |
| 11644 class TypeParameterList extends AstNode { | 10185 class TypeParameterListImpl extends AstNodeImpl implements TypeParameterList { |
| 11645 /** | 10186 /** |
| 11646 * The left angle bracket. | 10187 * The left angle bracket. |
| 11647 */ | 10188 */ |
| 11648 final Token leftBracket; | 10189 final Token leftBracket; |
| 11649 | 10190 |
| 11650 /** | 10191 /** |
| 11651 * The type parameters in the list. | 10192 * The type parameters in the list. |
| 11652 */ | 10193 */ |
| 11653 NodeList<TypeParameter> _typeParameters; | 10194 NodeList<TypeParameter> _typeParameters; |
| 11654 | 10195 |
| 11655 /** | 10196 /** |
| 11656 * The right angle bracket. | 10197 * The right angle bracket. |
| 11657 */ | 10198 */ |
| 11658 final Token rightBracket; | 10199 final Token rightBracket; |
| 11659 | 10200 |
| 11660 /** | 10201 /** |
| 11661 * Initialize a newly created list of type parameters. | 10202 * Initialize a newly created list of type parameters. |
| 11662 */ | 10203 */ |
| 11663 TypeParameterList( | 10204 TypeParameterListImpl( |
| 11664 this.leftBracket, List<TypeParameter> typeParameters, this.rightBracket) { | 10205 this.leftBracket, List<TypeParameter> typeParameters, this.rightBracket) { |
| 11665 _typeParameters = new NodeList<TypeParameter>(this, typeParameters); | 10206 _typeParameters = new NodeList<TypeParameter>(this, typeParameters); |
| 11666 } | 10207 } |
| 11667 | 10208 |
| 11668 @override | 10209 @override |
| 11669 Token get beginToken => leftBracket; | 10210 Token get beginToken => leftBracket; |
| 11670 | 10211 |
| 11671 @override | 10212 @override |
| 11672 Iterable get childEntities => new ChildEntities() | 10213 Iterable get childEntities => new ChildEntities() |
| 11673 ..add(leftBracket) | 10214 ..add(leftBracket) |
| 11674 ..addAll(_typeParameters) | 10215 ..addAll(_typeParameters) |
| 11675 ..add(rightBracket); | 10216 ..add(rightBracket); |
| 11676 | 10217 |
| 11677 @override | 10218 @override |
| 11678 Token get endToken => rightBracket; | 10219 Token get endToken => rightBracket; |
| 11679 | 10220 |
| 11680 /** | 10221 @override |
| 11681 * Return the type parameters for the type. | |
| 11682 */ | |
| 11683 NodeList<TypeParameter> get typeParameters => _typeParameters; | 10222 NodeList<TypeParameter> get typeParameters => _typeParameters; |
| 11684 | 10223 |
| 11685 @override | 10224 @override |
| 11686 accept(AstVisitor visitor) => visitor.visitTypeParameterList(this); | 10225 accept(AstVisitor visitor) => visitor.visitTypeParameterList(this); |
| 11687 | 10226 |
| 11688 @override | 10227 @override |
| 11689 void visitChildren(AstVisitor visitor) { | 10228 void visitChildren(AstVisitor visitor) { |
| 11690 _typeParameters.accept(visitor); | 10229 _typeParameters.accept(visitor); |
| 11691 } | 10230 } |
| 11692 } | 10231 } |
| 11693 | 10232 |
| 11694 /** | 10233 /** |
| 11695 * A directive that references a URI. | 10234 * A directive that references a URI. |
| 11696 * | 10235 * |
| 11697 * > uriBasedDirective ::= | 10236 * > uriBasedDirective ::= |
| 11698 * > [ExportDirective] | 10237 * > [ExportDirective] |
| 11699 * > | [ImportDirective] | 10238 * > | [ImportDirective] |
| 11700 * > | [PartDirective] | 10239 * > | [PartDirective] |
| 11701 */ | 10240 */ |
| 11702 abstract class UriBasedDirective extends Directive { | 10241 abstract class UriBasedDirectiveImpl extends DirectiveImpl |
| 10242 implements UriBasedDirective { |
| 11703 /** | 10243 /** |
| 11704 * The prefix of a URI using the `dart-ext` scheme to reference a native code | 10244 * The prefix of a URI using the `dart-ext` scheme to reference a native code |
| 11705 * library. | 10245 * library. |
| 11706 */ | 10246 */ |
| 11707 static String _DART_EXT_SCHEME = "dart-ext:"; | 10247 static String _DART_EXT_SCHEME = "dart-ext:"; |
| 11708 | 10248 |
| 11709 /** | 10249 /** |
| 11710 * The URI referenced by this directive. | 10250 * The URI referenced by this directive. |
| 11711 */ | 10251 */ |
| 11712 StringLiteral _uri; | 10252 StringLiteral _uri; |
| 11713 | 10253 |
| 11714 /** | 10254 /** |
| 11715 * The content of the URI. | 10255 * The content of the URI. |
| 11716 */ | 10256 */ |
| 11717 String uriContent; | 10257 String uriContent; |
| 11718 | 10258 |
| 11719 /** | 10259 /** |
| 11720 * The source to which the URI was resolved. | 10260 * The source to which the URI was resolved. |
| 11721 */ | 10261 */ |
| 11722 Source source; | 10262 Source source; |
| 11723 | 10263 |
| 11724 /** | 10264 /** |
| 11725 * Initialize a newly create URI-based directive. Either or both of the | 10265 * Initialize a newly create URI-based directive. Either or both of the |
| 11726 * [comment] and [metadata] can be `null` if the directive does not have the | 10266 * [comment] and [metadata] can be `null` if the directive does not have the |
| 11727 * corresponding attribute. | 10267 * corresponding attribute. |
| 11728 */ | 10268 */ |
| 11729 UriBasedDirective( | 10269 UriBasedDirectiveImpl( |
| 11730 Comment comment, List<Annotation> metadata, StringLiteral uri) | 10270 Comment comment, List<Annotation> metadata, StringLiteral uri) |
| 11731 : super(comment, metadata) { | 10271 : super(comment, metadata) { |
| 11732 _uri = _becomeParentOf(uri); | 10272 _uri = _becomeParentOf(uri); |
| 11733 } | 10273 } |
| 11734 | 10274 |
| 11735 /** | 10275 @override |
| 11736 * Return the URI referenced by this directive. | |
| 11737 */ | |
| 11738 StringLiteral get uri => _uri; | 10276 StringLiteral get uri => _uri; |
| 11739 | 10277 |
| 11740 /** | 10278 @override |
| 11741 * Set the URI referenced by this directive to the given [uri]. | |
| 11742 */ | |
| 11743 void set uri(StringLiteral uri) { | 10279 void set uri(StringLiteral uri) { |
| 11744 _uri = _becomeParentOf(uri); | 10280 _uri = _becomeParentOf(uri); |
| 11745 } | 10281 } |
| 11746 | 10282 |
| 11747 /** | 10283 @override |
| 11748 * Return the element associated with the URI of this directive, or `null` if | |
| 11749 * the AST structure has not been resolved or if the URI could not be | |
| 11750 * resolved. Examples of the latter case include a directive that contains an | |
| 11751 * invalid URL or a URL that does not exist. | |
| 11752 */ | |
| 11753 Element get uriElement; | |
| 11754 | |
| 11755 /** | |
| 11756 * Validate this directive, but do not check for existence. Return a code | |
| 11757 * indicating the problem if there is one, or `null` no problem | |
| 11758 */ | |
| 11759 UriValidationCode validate() { | 10284 UriValidationCode validate() { |
| 11760 StringLiteral uriLiteral = uri; | 10285 StringLiteral uriLiteral = uri; |
| 11761 if (uriLiteral is StringInterpolation) { | 10286 if (uriLiteral is StringInterpolation) { |
| 11762 return UriValidationCode.URI_WITH_INTERPOLATION; | 10287 return UriValidationCode.URI_WITH_INTERPOLATION; |
| 11763 } | 10288 } |
| 11764 String uriContent = this.uriContent; | 10289 String uriContent = this.uriContent; |
| 11765 if (uriContent == null) { | 10290 if (uriContent == null) { |
| 11766 return UriValidationCode.INVALID_URI; | 10291 return UriValidationCode.INVALID_URI; |
| 11767 } | 10292 } |
| 11768 if (this is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) { | 10293 if (this is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11779 @override | 10304 @override |
| 11780 void visitChildren(AstVisitor visitor) { | 10305 void visitChildren(AstVisitor visitor) { |
| 11781 super.visitChildren(visitor); | 10306 super.visitChildren(visitor); |
| 11782 _safelyVisitChild(_uri, visitor); | 10307 _safelyVisitChild(_uri, visitor); |
| 11783 } | 10308 } |
| 11784 } | 10309 } |
| 11785 | 10310 |
| 11786 /** | 10311 /** |
| 11787 * Validation codes returned by [UriBasedDirective.validate]. | 10312 * Validation codes returned by [UriBasedDirective.validate]. |
| 11788 */ | 10313 */ |
| 11789 class UriValidationCode { | 10314 class UriValidationCodeImpl implements UriValidationCode { |
| 11790 static const UriValidationCode INVALID_URI = | 10315 static const UriValidationCode INVALID_URI = |
| 11791 const UriValidationCode('INVALID_URI'); | 10316 const UriValidationCodeImpl('INVALID_URI'); |
| 11792 | 10317 |
| 11793 static const UriValidationCode URI_WITH_INTERPOLATION = | 10318 static const UriValidationCode URI_WITH_INTERPOLATION = |
| 11794 const UriValidationCode('URI_WITH_INTERPOLATION'); | 10319 const UriValidationCodeImpl('URI_WITH_INTERPOLATION'); |
| 11795 | 10320 |
| 11796 static const UriValidationCode URI_WITH_DART_EXT_SCHEME = | 10321 static const UriValidationCode URI_WITH_DART_EXT_SCHEME = |
| 11797 const UriValidationCode('URI_WITH_DART_EXT_SCHEME'); | 10322 const UriValidationCodeImpl('URI_WITH_DART_EXT_SCHEME'); |
| 11798 | 10323 |
| 11799 /** | 10324 /** |
| 11800 * The name of the validation code. | 10325 * The name of the validation code. |
| 11801 */ | 10326 */ |
| 11802 final String name; | 10327 final String name; |
| 11803 | 10328 |
| 11804 /** | 10329 /** |
| 11805 * Initialize a newly created validation code to have the given [name]. | 10330 * Initialize a newly created validation code to have the given [name]. |
| 11806 */ | 10331 */ |
| 11807 const UriValidationCode(this.name); | 10332 const UriValidationCodeImpl(this.name); |
| 11808 | 10333 |
| 11809 @override | 10334 @override |
| 11810 String toString() => name; | 10335 String toString() => name; |
| 11811 } | 10336 } |
| 11812 | 10337 |
| 11813 /** | 10338 /** |
| 11814 * An identifier that has an initial value associated with it. Instances of this | 10339 * An identifier that has an initial value associated with it. Instances of this |
| 11815 * class are always children of the class [VariableDeclarationList]. | 10340 * class are always children of the class [VariableDeclarationList]. |
| 11816 * | 10341 * |
| 11817 * > variableDeclaration ::= | 10342 * > variableDeclaration ::= |
| 11818 * > [SimpleIdentifier] ('=' [Expression])? | 10343 * > [SimpleIdentifier] ('=' [Expression])? |
| 11819 * | 10344 * |
| 11820 * TODO(paulberry): the grammar does not allow metadata to be associated with | 10345 * TODO(paulberry): the grammar does not allow metadata to be associated with |
| 11821 * a VariableDeclaration, and currently we don't record comments for it either. | 10346 * a VariableDeclaration, and currently we don't record comments for it either. |
| 11822 * Consider changing the class hierarchy so that [VariableDeclaration] does not | 10347 * Consider changing the class hierarchy so that [VariableDeclaration] does not |
| 11823 * extend [Declaration]. | 10348 * extend [Declaration]. |
| 11824 */ | 10349 */ |
| 11825 class VariableDeclaration extends Declaration { | 10350 class VariableDeclarationImpl extends DeclarationImpl |
| 10351 implements VariableDeclaration { |
| 11826 /** | 10352 /** |
| 11827 * The name of the variable being declared. | 10353 * The name of the variable being declared. |
| 11828 */ | 10354 */ |
| 11829 SimpleIdentifier _name; | 10355 SimpleIdentifier _name; |
| 11830 | 10356 |
| 11831 /** | 10357 /** |
| 11832 * The equal sign separating the variable name from the initial value, or | 10358 * The equal sign separating the variable name from the initial value, or |
| 11833 * `null` if the initial value was not specified. | 10359 * `null` if the initial value was not specified. |
| 11834 */ | 10360 */ |
| 11835 Token equals; | 10361 Token equals; |
| 11836 | 10362 |
| 11837 /** | 10363 /** |
| 11838 * The expression used to compute the initial value for the variable, or | 10364 * The expression used to compute the initial value for the variable, or |
| 11839 * `null` if the initial value was not specified. | 10365 * `null` if the initial value was not specified. |
| 11840 */ | 10366 */ |
| 11841 Expression _initializer; | 10367 Expression _initializer; |
| 11842 | 10368 |
| 11843 /** | 10369 /** |
| 11844 * Initialize a newly created variable declaration. The [equals] and | 10370 * Initialize a newly created variable declaration. The [equals] and |
| 11845 * [initializer] can be `null` if there is no initializer. | 10371 * [initializer] can be `null` if there is no initializer. |
| 11846 */ | 10372 */ |
| 11847 VariableDeclaration( | 10373 VariableDeclarationImpl( |
| 11848 SimpleIdentifier name, this.equals, Expression initializer) | 10374 SimpleIdentifier name, this.equals, Expression initializer) |
| 11849 : super(null, null) { | 10375 : super(null, null) { |
| 11850 _name = _becomeParentOf(name); | 10376 _name = _becomeParentOf(name); |
| 11851 _initializer = _becomeParentOf(initializer); | 10377 _initializer = _becomeParentOf(initializer); |
| 11852 } | 10378 } |
| 11853 | 10379 |
| 11854 @override | 10380 @override |
| 11855 Iterable get childEntities => | 10381 Iterable get childEntities => |
| 11856 super._childEntities..add(_name)..add(equals)..add(_initializer); | 10382 super._childEntities..add(_name)..add(equals)..add(_initializer); |
| 11857 | 10383 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 11882 Token get endToken { | 10408 Token get endToken { |
| 11883 if (_initializer != null) { | 10409 if (_initializer != null) { |
| 11884 return _initializer.endToken; | 10410 return _initializer.endToken; |
| 11885 } | 10411 } |
| 11886 return _name.endToken; | 10412 return _name.endToken; |
| 11887 } | 10413 } |
| 11888 | 10414 |
| 11889 @override | 10415 @override |
| 11890 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; | 10416 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; |
| 11891 | 10417 |
| 11892 /** | 10418 @override |
| 11893 * Return the expression used to compute the initial value for the variable, | |
| 11894 * or `null` if the initial value was not specified. | |
| 11895 */ | |
| 11896 Expression get initializer => _initializer; | 10419 Expression get initializer => _initializer; |
| 11897 | 10420 |
| 11898 /** | 10421 @override |
| 11899 * Set the expression used to compute the initial value for the variable to | |
| 11900 * the given [expression]. | |
| 11901 */ | |
| 11902 void set initializer(Expression expression) { | 10422 void set initializer(Expression expression) { |
| 11903 _initializer = _becomeParentOf(expression); | 10423 _initializer = _becomeParentOf(expression); |
| 11904 } | 10424 } |
| 11905 | 10425 |
| 11906 /** | 10426 @override |
| 11907 * Return `true` if this variable was declared with the 'const' modifier. | |
| 11908 */ | |
| 11909 bool get isConst { | 10427 bool get isConst { |
| 11910 AstNode parent = this.parent; | 10428 AstNode parent = this.parent; |
| 11911 return parent is VariableDeclarationList && parent.isConst; | 10429 return parent is VariableDeclarationList && parent.isConst; |
| 11912 } | 10430 } |
| 11913 | 10431 |
| 11914 /** | 10432 @override |
| 11915 * Return `true` if this variable was declared with the 'final' modifier. | |
| 11916 * Variables that are declared with the 'const' modifier will return `false` | |
| 11917 * even though they are implicitly final. | |
| 11918 */ | |
| 11919 bool get isFinal { | 10433 bool get isFinal { |
| 11920 AstNode parent = this.parent; | 10434 AstNode parent = this.parent; |
| 11921 return parent is VariableDeclarationList && parent.isFinal; | 10435 return parent is VariableDeclarationList && parent.isFinal; |
| 11922 } | 10436 } |
| 11923 | 10437 |
| 11924 /** | 10438 @override |
| 11925 * Return the name of the variable being declared. | |
| 11926 */ | |
| 11927 SimpleIdentifier get name => _name; | 10439 SimpleIdentifier get name => _name; |
| 11928 | 10440 |
| 11929 /** | 10441 @override |
| 11930 * Set the name of the variable being declared to the given [identifier]. | |
| 11931 */ | |
| 11932 void set name(SimpleIdentifier identifier) { | 10442 void set name(SimpleIdentifier identifier) { |
| 11933 _name = _becomeParentOf(identifier); | 10443 _name = _becomeParentOf(identifier); |
| 11934 } | 10444 } |
| 11935 | 10445 |
| 11936 @override | 10446 @override |
| 11937 accept(AstVisitor visitor) => visitor.visitVariableDeclaration(this); | 10447 accept(AstVisitor visitor) => visitor.visitVariableDeclaration(this); |
| 11938 | 10448 |
| 11939 @override | 10449 @override |
| 11940 void visitChildren(AstVisitor visitor) { | 10450 void visitChildren(AstVisitor visitor) { |
| 11941 super.visitChildren(visitor); | 10451 super.visitChildren(visitor); |
| 11942 _safelyVisitChild(_name, visitor); | 10452 _safelyVisitChild(_name, visitor); |
| 11943 _safelyVisitChild(_initializer, visitor); | 10453 _safelyVisitChild(_initializer, visitor); |
| 11944 } | 10454 } |
| 11945 } | 10455 } |
| 11946 | 10456 |
| 11947 /** | 10457 /** |
| 11948 * The declaration of one or more variables of the same type. | 10458 * The declaration of one or more variables of the same type. |
| 11949 * | 10459 * |
| 11950 * > variableDeclarationList ::= | 10460 * > variableDeclarationList ::= |
| 11951 * > finalConstVarOrType [VariableDeclaration] (',' [VariableDeclaration])* | 10461 * > finalConstVarOrType [VariableDeclaration] (',' [VariableDeclaration])* |
| 11952 * > | 10462 * > |
| 11953 * > finalConstVarOrType ::= | 10463 * > finalConstVarOrType ::= |
| 11954 * > | 'final' [TypeName]? | 10464 * > | 'final' [TypeName]? |
| 11955 * > | 'const' [TypeName]? | 10465 * > | 'const' [TypeName]? |
| 11956 * > | 'var' | 10466 * > | 'var' |
| 11957 * > | [TypeName] | 10467 * > | [TypeName] |
| 11958 */ | 10468 */ |
| 11959 class VariableDeclarationList extends AnnotatedNode { | 10469 class VariableDeclarationListImpl extends AnnotatedNodeImpl |
| 10470 implements VariableDeclarationList { |
| 11960 /** | 10471 /** |
| 11961 * The token representing the 'final', 'const' or 'var' keyword, or `null` if | 10472 * The token representing the 'final', 'const' or 'var' keyword, or `null` if |
| 11962 * no keyword was included. | 10473 * no keyword was included. |
| 11963 */ | 10474 */ |
| 11964 Token keyword; | 10475 Token keyword; |
| 11965 | 10476 |
| 11966 /** | 10477 /** |
| 11967 * The type of the variables being declared, or `null` if no type was provided
. | 10478 * The type of the variables being declared, or `null` if no type was provided
. |
| 11968 */ | 10479 */ |
| 11969 TypeName _type; | 10480 TypeName _type; |
| 11970 | 10481 |
| 11971 /** | 10482 /** |
| 11972 * A list containing the individual variables being declared. | 10483 * A list containing the individual variables being declared. |
| 11973 */ | 10484 */ |
| 11974 NodeList<VariableDeclaration> _variables; | 10485 NodeList<VariableDeclaration> _variables; |
| 11975 | 10486 |
| 11976 /** | 10487 /** |
| 11977 * Initialize a newly created variable declaration list. Either or both of the | 10488 * Initialize a newly created variable declaration list. Either or both of the |
| 11978 * [comment] and [metadata] can be `null` if the variable list does not have | 10489 * [comment] and [metadata] can be `null` if the variable list does not have |
| 11979 * the corresponding attribute. The [keyword] can be `null` if a type was | 10490 * the corresponding attribute. The [keyword] can be `null` if a type was |
| 11980 * specified. The [type] must be `null` if the keyword is 'var'. | 10491 * specified. The [type] must be `null` if the keyword is 'var'. |
| 11981 */ | 10492 */ |
| 11982 VariableDeclarationList(Comment comment, List<Annotation> metadata, | 10493 VariableDeclarationListImpl(Comment comment, List<Annotation> metadata, |
| 11983 this.keyword, TypeName type, List<VariableDeclaration> variables) | 10494 this.keyword, TypeName type, List<VariableDeclaration> variables) |
| 11984 : super(comment, metadata) { | 10495 : super(comment, metadata) { |
| 11985 _type = _becomeParentOf(type); | 10496 _type = _becomeParentOf(type); |
| 11986 _variables = new NodeList<VariableDeclaration>(this, variables); | 10497 _variables = new NodeList<VariableDeclaration>(this, variables); |
| 11987 } | 10498 } |
| 11988 | 10499 |
| 11989 @override | 10500 @override |
| 11990 // TODO(paulberry): include commas. | 10501 // TODO(paulberry): include commas. |
| 11991 Iterable get childEntities => super._childEntities | 10502 Iterable get childEntities => super._childEntities |
| 11992 ..add(keyword) | 10503 ..add(keyword) |
| 11993 ..add(_type) | 10504 ..add(_type) |
| 11994 ..addAll(_variables); | 10505 ..addAll(_variables); |
| 11995 | 10506 |
| 11996 @override | 10507 @override |
| 11997 Token get endToken => _variables.endToken; | 10508 Token get endToken => _variables.endToken; |
| 11998 | 10509 |
| 11999 @override | 10510 @override |
| 12000 Token get firstTokenAfterCommentAndMetadata { | 10511 Token get firstTokenAfterCommentAndMetadata { |
| 12001 if (keyword != null) { | 10512 if (keyword != null) { |
| 12002 return keyword; | 10513 return keyword; |
| 12003 } else if (_type != null) { | 10514 } else if (_type != null) { |
| 12004 return _type.beginToken; | 10515 return _type.beginToken; |
| 12005 } | 10516 } |
| 12006 return _variables.beginToken; | 10517 return _variables.beginToken; |
| 12007 } | 10518 } |
| 12008 | 10519 |
| 12009 /** | 10520 @override |
| 12010 * Return `true` if the variables in this list were declared with the 'const' | |
| 12011 * modifier. | |
| 12012 */ | |
| 12013 bool get isConst => | 10521 bool get isConst => |
| 12014 keyword is KeywordToken && | 10522 keyword is KeywordToken && |
| 12015 (keyword as KeywordToken).keyword == Keyword.CONST; | 10523 (keyword as KeywordToken).keyword == Keyword.CONST; |
| 12016 | 10524 |
| 12017 /** | 10525 @override |
| 12018 * Return `true` if the variables in this list were declared with the 'final' | |
| 12019 * modifier. Variables that are declared with the 'const' modifier will return | |
| 12020 * `false` even though they are implicitly final. (In other words, this is a | |
| 12021 * syntactic check rather than a semantic check.) | |
| 12022 */ | |
| 12023 bool get isFinal => | 10526 bool get isFinal => |
| 12024 keyword is KeywordToken && | 10527 keyword is KeywordToken && |
| 12025 (keyword as KeywordToken).keyword == Keyword.FINAL; | 10528 (keyword as KeywordToken).keyword == Keyword.FINAL; |
| 12026 | 10529 |
| 12027 /** | 10530 @override |
| 12028 * Return the type of the variables being declared, or `null` if no type was | |
| 12029 * provided. | |
| 12030 */ | |
| 12031 TypeName get type => _type; | 10531 TypeName get type => _type; |
| 12032 | 10532 |
| 12033 /** | 10533 @override |
| 12034 * Set the type of the variables being declared to the given [typeName]. | |
| 12035 */ | |
| 12036 void set type(TypeName typeName) { | 10534 void set type(TypeName typeName) { |
| 12037 _type = _becomeParentOf(typeName); | 10535 _type = _becomeParentOf(typeName); |
| 12038 } | 10536 } |
| 12039 | 10537 |
| 12040 /** | 10538 @override |
| 12041 * Return a list containing the individual variables being declared. | |
| 12042 */ | |
| 12043 NodeList<VariableDeclaration> get variables => _variables; | 10539 NodeList<VariableDeclaration> get variables => _variables; |
| 12044 | 10540 |
| 12045 @override | 10541 @override |
| 12046 accept(AstVisitor visitor) => visitor.visitVariableDeclarationList(this); | 10542 accept(AstVisitor visitor) => visitor.visitVariableDeclarationList(this); |
| 12047 | 10543 |
| 12048 @override | 10544 @override |
| 12049 void visitChildren(AstVisitor visitor) { | 10545 void visitChildren(AstVisitor visitor) { |
| 12050 super.visitChildren(visitor); | 10546 super.visitChildren(visitor); |
| 12051 _safelyVisitChild(_type, visitor); | 10547 _safelyVisitChild(_type, visitor); |
| 12052 _variables.accept(visitor); | 10548 _variables.accept(visitor); |
| 12053 } | 10549 } |
| 12054 } | 10550 } |
| 12055 | 10551 |
| 12056 /** | 10552 /** |
| 12057 * A list of variables that are being declared in a context where a statement is | 10553 * A list of variables that are being declared in a context where a statement is |
| 12058 * required. | 10554 * required. |
| 12059 * | 10555 * |
| 12060 * > variableDeclarationStatement ::= | 10556 * > variableDeclarationStatement ::= |
| 12061 * > [VariableDeclarationList] ';' | 10557 * > [VariableDeclarationList] ';' |
| 12062 */ | 10558 */ |
| 12063 class VariableDeclarationStatement extends Statement { | 10559 class VariableDeclarationStatementImpl extends StatementImpl |
| 10560 implements VariableDeclarationStatement { |
| 12064 /** | 10561 /** |
| 12065 * The variables being declared. | 10562 * The variables being declared. |
| 12066 */ | 10563 */ |
| 12067 VariableDeclarationList _variableList; | 10564 VariableDeclarationList _variableList; |
| 12068 | 10565 |
| 12069 /** | 10566 /** |
| 12070 * The semicolon terminating the statement. | 10567 * The semicolon terminating the statement. |
| 12071 */ | 10568 */ |
| 12072 Token semicolon; | 10569 Token semicolon; |
| 12073 | 10570 |
| 12074 /** | 10571 /** |
| 12075 * Initialize a newly created variable declaration statement. | 10572 * Initialize a newly created variable declaration statement. |
| 12076 */ | 10573 */ |
| 12077 VariableDeclarationStatement( | 10574 VariableDeclarationStatementImpl( |
| 12078 VariableDeclarationList variableList, this.semicolon) { | 10575 VariableDeclarationList variableList, this.semicolon) { |
| 12079 _variableList = _becomeParentOf(variableList); | 10576 _variableList = _becomeParentOf(variableList); |
| 12080 } | 10577 } |
| 12081 | 10578 |
| 12082 @override | 10579 @override |
| 12083 Token get beginToken => _variableList.beginToken; | 10580 Token get beginToken => _variableList.beginToken; |
| 12084 | 10581 |
| 12085 @override | 10582 @override |
| 12086 Iterable get childEntities => | 10583 Iterable get childEntities => |
| 12087 new ChildEntities()..add(_variableList)..add(semicolon); | 10584 new ChildEntities()..add(_variableList)..add(semicolon); |
| 12088 | 10585 |
| 12089 @override | 10586 @override |
| 12090 Token get endToken => semicolon; | 10587 Token get endToken => semicolon; |
| 12091 | 10588 |
| 12092 /** | 10589 @override |
| 12093 * Return the variables being declared. | |
| 12094 */ | |
| 12095 VariableDeclarationList get variables => _variableList; | 10590 VariableDeclarationList get variables => _variableList; |
| 12096 | 10591 |
| 12097 /** | 10592 @override |
| 12098 * Set the variables being declared to the given list of [variables]. | |
| 12099 */ | |
| 12100 void set variables(VariableDeclarationList variables) { | 10593 void set variables(VariableDeclarationList variables) { |
| 12101 _variableList = _becomeParentOf(variables); | 10594 _variableList = _becomeParentOf(variables); |
| 12102 } | 10595 } |
| 12103 | 10596 |
| 12104 @override | 10597 @override |
| 12105 accept(AstVisitor visitor) => visitor.visitVariableDeclarationStatement(this); | 10598 accept(AstVisitor visitor) => visitor.visitVariableDeclarationStatement(this); |
| 12106 | 10599 |
| 12107 @override | 10600 @override |
| 12108 void visitChildren(AstVisitor visitor) { | 10601 void visitChildren(AstVisitor visitor) { |
| 12109 _safelyVisitChild(_variableList, visitor); | 10602 _safelyVisitChild(_variableList, visitor); |
| 12110 } | 10603 } |
| 12111 } | 10604 } |
| 12112 | 10605 |
| 12113 /** | 10606 /** |
| 12114 * A while statement. | 10607 * A while statement. |
| 12115 * | 10608 * |
| 12116 * > whileStatement ::= | 10609 * > whileStatement ::= |
| 12117 * > 'while' '(' [Expression] ')' [Statement] | 10610 * > 'while' '(' [Expression] ')' [Statement] |
| 12118 */ | 10611 */ |
| 12119 class WhileStatement extends Statement { | 10612 class WhileStatementImpl extends StatementImpl implements WhileStatement { |
| 12120 /** | 10613 /** |
| 12121 * The token representing the 'while' keyword. | 10614 * The token representing the 'while' keyword. |
| 12122 */ | 10615 */ |
| 12123 Token whileKeyword; | 10616 Token whileKeyword; |
| 12124 | 10617 |
| 12125 /** | 10618 /** |
| 12126 * The left parenthesis. | 10619 * The left parenthesis. |
| 12127 */ | 10620 */ |
| 12128 Token leftParenthesis; | 10621 Token leftParenthesis; |
| 12129 | 10622 |
| 12130 /** | 10623 /** |
| 12131 * The expression used to determine whether to execute the body of the loop. | 10624 * The expression used to determine whether to execute the body of the loop. |
| 12132 */ | 10625 */ |
| 12133 Expression _condition; | 10626 Expression _condition; |
| 12134 | 10627 |
| 12135 /** | 10628 /** |
| 12136 * The right parenthesis. | 10629 * The right parenthesis. |
| 12137 */ | 10630 */ |
| 12138 Token rightParenthesis; | 10631 Token rightParenthesis; |
| 12139 | 10632 |
| 12140 /** | 10633 /** |
| 12141 * The body of the loop. | 10634 * The body of the loop. |
| 12142 */ | 10635 */ |
| 12143 Statement _body; | 10636 Statement _body; |
| 12144 | 10637 |
| 12145 /** | 10638 /** |
| 12146 * Initialize a newly created while statement. | 10639 * Initialize a newly created while statement. |
| 12147 */ | 10640 */ |
| 12148 WhileStatement(this.whileKeyword, this.leftParenthesis, Expression condition, | 10641 WhileStatementImpl(this.whileKeyword, this.leftParenthesis, |
| 12149 this.rightParenthesis, Statement body) { | 10642 Expression condition, this.rightParenthesis, Statement body) { |
| 12150 _condition = _becomeParentOf(condition); | 10643 _condition = _becomeParentOf(condition); |
| 12151 _body = _becomeParentOf(body); | 10644 _body = _becomeParentOf(body); |
| 12152 } | 10645 } |
| 12153 | 10646 |
| 12154 @override | 10647 @override |
| 12155 Token get beginToken => whileKeyword; | 10648 Token get beginToken => whileKeyword; |
| 12156 | 10649 |
| 12157 /** | 10650 @override |
| 12158 * Return the body of the loop. | |
| 12159 */ | |
| 12160 Statement get body => _body; | 10651 Statement get body => _body; |
| 12161 | 10652 |
| 12162 /** | 10653 @override |
| 12163 * Set the body of the loop to the given [statement]. | |
| 12164 */ | |
| 12165 void set body(Statement statement) { | 10654 void set body(Statement statement) { |
| 12166 _body = _becomeParentOf(statement); | 10655 _body = _becomeParentOf(statement); |
| 12167 } | 10656 } |
| 12168 | 10657 |
| 12169 @override | 10658 @override |
| 12170 Iterable get childEntities => new ChildEntities() | 10659 Iterable get childEntities => new ChildEntities() |
| 12171 ..add(whileKeyword) | 10660 ..add(whileKeyword) |
| 12172 ..add(leftParenthesis) | 10661 ..add(leftParenthesis) |
| 12173 ..add(_condition) | 10662 ..add(_condition) |
| 12174 ..add(rightParenthesis) | 10663 ..add(rightParenthesis) |
| 12175 ..add(_body); | 10664 ..add(_body); |
| 12176 | 10665 |
| 12177 /** | 10666 @override |
| 12178 * Return the expression used to determine whether to execute the body of the | |
| 12179 * loop. | |
| 12180 */ | |
| 12181 Expression get condition => _condition; | 10667 Expression get condition => _condition; |
| 12182 | 10668 |
| 12183 /** | 10669 @override |
| 12184 * Set the expression used to determine whether to execute the body of the | |
| 12185 * loop to the given [expression]. | |
| 12186 */ | |
| 12187 void set condition(Expression expression) { | 10670 void set condition(Expression expression) { |
| 12188 _condition = _becomeParentOf(expression); | 10671 _condition = _becomeParentOf(expression); |
| 12189 } | 10672 } |
| 12190 | 10673 |
| 12191 @override | 10674 @override |
| 12192 Token get endToken => _body.endToken; | 10675 Token get endToken => _body.endToken; |
| 12193 | 10676 |
| 12194 @override | 10677 @override |
| 12195 accept(AstVisitor visitor) => visitor.visitWhileStatement(this); | 10678 accept(AstVisitor visitor) => visitor.visitWhileStatement(this); |
| 12196 | 10679 |
| 12197 @override | 10680 @override |
| 12198 void visitChildren(AstVisitor visitor) { | 10681 void visitChildren(AstVisitor visitor) { |
| 12199 _safelyVisitChild(_condition, visitor); | 10682 _safelyVisitChild(_condition, visitor); |
| 12200 _safelyVisitChild(_body, visitor); | 10683 _safelyVisitChild(_body, visitor); |
| 12201 } | 10684 } |
| 12202 } | 10685 } |
| 12203 | 10686 |
| 12204 /** | 10687 /** |
| 12205 * The with clause in a class declaration. | 10688 * The with clause in a class declaration. |
| 12206 * | 10689 * |
| 12207 * > withClause ::= | 10690 * > withClause ::= |
| 12208 * > 'with' [TypeName] (',' [TypeName])* | 10691 * > 'with' [TypeName] (',' [TypeName])* |
| 12209 */ | 10692 */ |
| 12210 class WithClause extends AstNode { | 10693 class WithClauseImpl extends AstNodeImpl implements WithClause { |
| 12211 /** | 10694 /** |
| 12212 * The token representing the 'with' keyword. | 10695 * The token representing the 'with' keyword. |
| 12213 */ | 10696 */ |
| 12214 Token withKeyword; | 10697 Token withKeyword; |
| 12215 | 10698 |
| 12216 /** | 10699 /** |
| 12217 * The names of the mixins that were specified. | 10700 * The names of the mixins that were specified. |
| 12218 */ | 10701 */ |
| 12219 NodeList<TypeName> _mixinTypes; | 10702 NodeList<TypeName> _mixinTypes; |
| 12220 | 10703 |
| 12221 /** | 10704 /** |
| 12222 * Initialize a newly created with clause. | 10705 * Initialize a newly created with clause. |
| 12223 */ | 10706 */ |
| 12224 WithClause(this.withKeyword, List<TypeName> mixinTypes) { | 10707 WithClauseImpl(this.withKeyword, List<TypeName> mixinTypes) { |
| 12225 _mixinTypes = new NodeList<TypeName>(this, mixinTypes); | 10708 _mixinTypes = new NodeList<TypeName>(this, mixinTypes); |
| 12226 } | 10709 } |
| 12227 | 10710 |
| 12228 @override | 10711 @override |
| 12229 Token get beginToken => withKeyword; | 10712 Token get beginToken => withKeyword; |
| 12230 | 10713 |
| 12231 @override | 10714 @override |
| 12232 // TODO(paulberry): add commas. | 10715 // TODO(paulberry): add commas. |
| 12233 Iterable get childEntities => new ChildEntities() | 10716 Iterable get childEntities => new ChildEntities() |
| 12234 ..add(withKeyword) | 10717 ..add(withKeyword) |
| 12235 ..addAll(_mixinTypes); | 10718 ..addAll(_mixinTypes); |
| 12236 | 10719 |
| 12237 @override | 10720 @override |
| 12238 Token get endToken => _mixinTypes.endToken; | 10721 Token get endToken => _mixinTypes.endToken; |
| 12239 | 10722 |
| 12240 /** | 10723 @override |
| 12241 * Return the names of the mixins that were specified. | |
| 12242 */ | |
| 12243 NodeList<TypeName> get mixinTypes => _mixinTypes; | 10724 NodeList<TypeName> get mixinTypes => _mixinTypes; |
| 12244 | 10725 |
| 12245 @override | 10726 @override |
| 12246 accept(AstVisitor visitor) => visitor.visitWithClause(this); | 10727 accept(AstVisitor visitor) => visitor.visitWithClause(this); |
| 12247 | 10728 |
| 12248 @override | 10729 @override |
| 12249 void visitChildren(AstVisitor visitor) { | 10730 void visitChildren(AstVisitor visitor) { |
| 12250 _mixinTypes.accept(visitor); | 10731 _mixinTypes.accept(visitor); |
| 12251 } | 10732 } |
| 12252 } | 10733 } |
| 12253 | 10734 |
| 12254 /** | 10735 /** |
| 12255 * A yield statement. | 10736 * A yield statement. |
| 12256 * | 10737 * |
| 12257 * > yieldStatement ::= | 10738 * > yieldStatement ::= |
| 12258 * > 'yield' '*'? [Expression] ‘;’ | 10739 * > 'yield' '*'? [Expression] ‘;’ |
| 12259 */ | 10740 */ |
| 12260 class YieldStatement extends Statement { | 10741 class YieldStatementImpl extends StatementImpl implements YieldStatement { |
| 12261 /** | 10742 /** |
| 12262 * The 'yield' keyword. | 10743 * The 'yield' keyword. |
| 12263 */ | 10744 */ |
| 12264 Token yieldKeyword; | 10745 Token yieldKeyword; |
| 12265 | 10746 |
| 12266 /** | 10747 /** |
| 12267 * The star optionally following the 'yield' keyword. | 10748 * The star optionally following the 'yield' keyword. |
| 12268 */ | 10749 */ |
| 12269 Token star; | 10750 Token star; |
| 12270 | 10751 |
| 12271 /** | 10752 /** |
| 12272 * The expression whose value will be yielded. | 10753 * The expression whose value will be yielded. |
| 12273 */ | 10754 */ |
| 12274 Expression _expression; | 10755 Expression _expression; |
| 12275 | 10756 |
| 12276 /** | 10757 /** |
| 12277 * The semicolon following the expression. | 10758 * The semicolon following the expression. |
| 12278 */ | 10759 */ |
| 12279 Token semicolon; | 10760 Token semicolon; |
| 12280 | 10761 |
| 12281 /** | 10762 /** |
| 12282 * Initialize a newly created yield expression. The [star] can be `null` if no | 10763 * Initialize a newly created yield expression. The [star] can be `null` if no |
| 12283 * star was provided. | 10764 * star was provided. |
| 12284 */ | 10765 */ |
| 12285 YieldStatement( | 10766 YieldStatementImpl( |
| 12286 this.yieldKeyword, this.star, Expression expression, this.semicolon) { | 10767 this.yieldKeyword, this.star, Expression expression, this.semicolon) { |
| 12287 _expression = _becomeParentOf(expression); | 10768 _expression = _becomeParentOf(expression); |
| 12288 } | 10769 } |
| 12289 | 10770 |
| 12290 @override | 10771 @override |
| 12291 Token get beginToken { | 10772 Token get beginToken { |
| 12292 if (yieldKeyword != null) { | 10773 if (yieldKeyword != null) { |
| 12293 return yieldKeyword; | 10774 return yieldKeyword; |
| 12294 } | 10775 } |
| 12295 return _expression.beginToken; | 10776 return _expression.beginToken; |
| 12296 } | 10777 } |
| 12297 | 10778 |
| 12298 @override | 10779 @override |
| 12299 Iterable get childEntities => new ChildEntities() | 10780 Iterable get childEntities => new ChildEntities() |
| 12300 ..add(yieldKeyword) | 10781 ..add(yieldKeyword) |
| 12301 ..add(star) | 10782 ..add(star) |
| 12302 ..add(_expression) | 10783 ..add(_expression) |
| 12303 ..add(semicolon); | 10784 ..add(semicolon); |
| 12304 | 10785 |
| 12305 @override | 10786 @override |
| 12306 Token get endToken { | 10787 Token get endToken { |
| 12307 if (semicolon != null) { | 10788 if (semicolon != null) { |
| 12308 return semicolon; | 10789 return semicolon; |
| 12309 } | 10790 } |
| 12310 return _expression.endToken; | 10791 return _expression.endToken; |
| 12311 } | 10792 } |
| 12312 | 10793 |
| 12313 /** | 10794 @override |
| 12314 * Return the expression whose value will be yielded. | |
| 12315 */ | |
| 12316 Expression get expression => _expression; | 10795 Expression get expression => _expression; |
| 12317 | 10796 |
| 12318 /** | 10797 @override |
| 12319 * Set the expression whose value will be yielded to the given [expression]. | |
| 12320 */ | |
| 12321 void set expression(Expression expression) { | 10798 void set expression(Expression expression) { |
| 12322 _expression = _becomeParentOf(expression); | 10799 _expression = _becomeParentOf(expression); |
| 12323 } | 10800 } |
| 12324 | 10801 |
| 12325 @override | 10802 @override |
| 12326 accept(AstVisitor visitor) => visitor.visitYieldStatement(this); | 10803 accept(AstVisitor visitor) => visitor.visitYieldStatement(this); |
| 12327 | 10804 |
| 12328 @override | 10805 @override |
| 12329 void visitChildren(AstVisitor visitor) { | 10806 void visitChildren(AstVisitor visitor) { |
| 12330 _safelyVisitChild(_expression, visitor); | 10807 _safelyVisitChild(_expression, visitor); |
| 12331 } | 10808 } |
| 12332 } | 10809 } |
| OLD | NEW |