OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 | 3 |
4 library engine.ast; | 4 library engine.ast; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
9 import 'source.dart' show LineInfo; | 9 import 'source.dart' show LineInfo; |
10 import 'scanner.dart'; | 10 import 'scanner.dart'; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 * there is no enclosing node of the given class. | 57 * there is no enclosing node of the given class. |
58 * | 58 * |
59 * @param nodeClass the class of the node to be returned | 59 * @param nodeClass the class of the node to be returned |
60 * @return the node of the given type that encloses this node | 60 * @return the node of the given type that encloses this node |
61 */ | 61 */ |
62 ASTNode getAncestor(Type enclosingClass) { | 62 ASTNode getAncestor(Type enclosingClass) { |
63 ASTNode node = this; | 63 ASTNode node = this; |
64 while (node != null && !isInstanceOf(node, enclosingClass)) { | 64 while (node != null && !isInstanceOf(node, enclosingClass)) { |
65 node = node.parent; | 65 node = node.parent; |
66 } | 66 } |
67 return node as ASTNode; | 67 return node; |
68 } | 68 } |
69 | 69 |
70 /** | 70 /** |
71 * Return the first token included in this node's source range. | 71 * Return the first token included in this node's source range. |
72 * | 72 * |
73 * @return the first token included in this node's source range | 73 * @return the first token included in this node's source range |
74 */ | 74 */ |
75 Token get beginToken; | 75 Token get beginToken; |
76 | 76 |
77 /** | 77 /** |
(...skipping 2118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 this._name = becomeParentOf(name); | 2196 this._name = becomeParentOf(name); |
2197 this.typeParameters = becomeParentOf(typeParameters); | 2197 this.typeParameters = becomeParentOf(typeParameters); |
2198 this._extendsClause = becomeParentOf(extendsClause); | 2198 this._extendsClause = becomeParentOf(extendsClause); |
2199 this._withClause = becomeParentOf(withClause); | 2199 this._withClause = becomeParentOf(withClause); |
2200 this._implementsClause = becomeParentOf(implementsClause); | 2200 this._implementsClause = becomeParentOf(implementsClause); |
2201 this._members.addAll(members); | 2201 this._members.addAll(members); |
2202 } | 2202 } |
2203 | 2203 |
2204 accept(ASTVisitor visitor) => visitor.visitClassDeclaration(this); | 2204 accept(ASTVisitor visitor) => visitor.visitClassDeclaration(this); |
2205 | 2205 |
| 2206 /** |
| 2207 * Return the constructor declared in the class with the given name. |
| 2208 * |
| 2209 * @param name the name of the constructor to find, `null` for default |
| 2210 * @return the found constructor or `null` if not found |
| 2211 */ |
| 2212 ConstructorDeclaration getConstructor(String name) { |
| 2213 for (ClassMember classMember in _members) { |
| 2214 if (classMember is ConstructorDeclaration) { |
| 2215 ConstructorDeclaration constructor = classMember; |
| 2216 SimpleIdentifier constructorName = constructor.name; |
| 2217 if (name == null && constructorName == null) { |
| 2218 return constructor; |
| 2219 } |
| 2220 if (constructorName != null && constructorName.name == name) { |
| 2221 return constructor; |
| 2222 } |
| 2223 } |
| 2224 } |
| 2225 return null; |
| 2226 } |
| 2227 |
2206 ClassElement get element => _name != null ? (_name.staticElement as ClassEleme
nt) : null; | 2228 ClassElement get element => _name != null ? (_name.staticElement as ClassEleme
nt) : null; |
2207 | 2229 |
2208 Token get endToken => rightBracket; | 2230 Token get endToken => rightBracket; |
2209 | 2231 |
2210 /** | 2232 /** |
2211 * Return the extends clause for this class, or `null` if the class does not e
xtend any | 2233 * Return the extends clause for this class, or `null` if the class does not e
xtend any |
2212 * other class. | 2234 * other class. |
2213 * | 2235 * |
2214 * @return the extends clause for this class | 2236 * @return the extends clause for this class |
2215 */ | 2237 */ |
2216 ExtendsClause get extendsClause => _extendsClause; | 2238 ExtendsClause get extendsClause => _extendsClause; |
2217 | 2239 |
2218 /** | 2240 /** |
2219 * Return the field declared in the class with the given name. | 2241 * Return the field declared in the class with the given name. |
2220 * | 2242 * |
2221 * @param name the name of the field to find | 2243 * @param name the name of the field to find |
2222 * @return the found field or `null` if not found | 2244 * @return the found field or `null` if not found |
2223 */ | 2245 */ |
2224 VariableDeclaration getField(String name) { | 2246 VariableDeclaration getField(String name) { |
2225 for (ClassMember classMember in _members) { | 2247 for (ClassMember classMember in _members) { |
2226 if (classMember is FieldDeclaration) { | 2248 if (classMember is FieldDeclaration) { |
2227 FieldDeclaration fieldDeclaration = classMember as FieldDeclaration; | 2249 FieldDeclaration fieldDeclaration = classMember; |
2228 NodeList<VariableDeclaration> fields = fieldDeclaration.fields.variables
; | 2250 NodeList<VariableDeclaration> fields = fieldDeclaration.fields.variables
; |
2229 for (VariableDeclaration field in fields) { | 2251 for (VariableDeclaration field in fields) { |
2230 SimpleIdentifier fieldName = field.name; | 2252 SimpleIdentifier fieldName = field.name; |
2231 if (fieldName != null && name == fieldName.name) { | 2253 if (fieldName != null && name == fieldName.name) { |
2232 return field; | 2254 return field; |
2233 } | 2255 } |
2234 } | 2256 } |
2235 } | 2257 } |
2236 } | 2258 } |
2237 return null; | 2259 return null; |
2238 } | 2260 } |
2239 | 2261 |
2240 /** | 2262 /** |
2241 * Return the implements clause for the class, or `null` if the class does not
implement any | 2263 * Return the implements clause for the class, or `null` if the class does not
implement any |
2242 * interfaces. | 2264 * interfaces. |
2243 * | 2265 * |
2244 * @return the implements clause for the class | 2266 * @return the implements clause for the class |
2245 */ | 2267 */ |
2246 ImplementsClause get implementsClause => _implementsClause; | 2268 ImplementsClause get implementsClause => _implementsClause; |
2247 | 2269 |
2248 /** | 2270 /** |
2249 * Return the members defined by the class. | 2271 * Return the members defined by the class. |
2250 * | 2272 * |
2251 * @return the members defined by the class | 2273 * @return the members defined by the class |
2252 */ | 2274 */ |
2253 NodeList<ClassMember> get members => _members; | 2275 NodeList<ClassMember> get members => _members; |
2254 | 2276 |
2255 /** | 2277 /** |
| 2278 * Return the method declared in the class with the given name. |
| 2279 * |
| 2280 * @param name the name of the method to find |
| 2281 * @return the found method or `null` if not found |
| 2282 */ |
| 2283 MethodDeclaration getMethod(String name) { |
| 2284 for (ClassMember classMember in _members) { |
| 2285 if (classMember is MethodDeclaration) { |
| 2286 MethodDeclaration method = classMember; |
| 2287 SimpleIdentifier methodName = method.name; |
| 2288 if (methodName != null && name == methodName.name) { |
| 2289 return method; |
| 2290 } |
| 2291 } |
| 2292 } |
| 2293 return null; |
| 2294 } |
| 2295 |
| 2296 /** |
2256 * Return the name of the class being declared. | 2297 * Return the name of the class being declared. |
2257 * | 2298 * |
2258 * @return the name of the class being declared | 2299 * @return the name of the class being declared |
2259 */ | 2300 */ |
2260 SimpleIdentifier get name => _name; | 2301 SimpleIdentifier get name => _name; |
2261 | 2302 |
2262 /** | 2303 /** |
2263 * Return the with clause for the class, or `null` if the class does not have
a with clause. | 2304 * Return the with clause for the class, or `null` if the class does not have
a with clause. |
2264 * | 2305 * |
2265 * @return the with clause for the class | 2306 * @return the with clause for the class |
(...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 * @param combinators the combinators used to control which names are exported | 4238 * @param combinators the combinators used to control which names are exported |
4198 * @param semicolon the semicolon terminating the directive | 4239 * @param semicolon the semicolon terminating the directive |
4199 */ | 4240 */ |
4200 ExportDirective(Comment comment, List<Annotation> metadata, Token keyword, Str
ingLiteral libraryUri, List<Combinator> combinators, Token semicolon) : super(co
mment, metadata, keyword, libraryUri, combinators, semicolon); | 4241 ExportDirective(Comment comment, List<Annotation> metadata, Token keyword, Str
ingLiteral libraryUri, List<Combinator> combinators, Token semicolon) : super(co
mment, metadata, keyword, libraryUri, combinators, semicolon); |
4201 | 4242 |
4202 accept(ASTVisitor visitor) => visitor.visitExportDirective(this); | 4243 accept(ASTVisitor visitor) => visitor.visitExportDirective(this); |
4203 | 4244 |
4204 LibraryElement get uriElement { | 4245 LibraryElement get uriElement { |
4205 Element element = this.element; | 4246 Element element = this.element; |
4206 if (element is ExportElement) { | 4247 if (element is ExportElement) { |
4207 return (element as ExportElement).exportedLibrary; | 4248 return element.exportedLibrary; |
4208 } | 4249 } |
4209 return null; | 4250 return null; |
4210 } | 4251 } |
4211 | 4252 |
4212 void visitChildren(ASTVisitor visitor) { | 4253 void visitChildren(ASTVisitor visitor) { |
4213 super.visitChildren(visitor); | 4254 super.visitChildren(visitor); |
4214 combinators.accept(visitor); | 4255 combinators.accept(visitor); |
4215 } | 4256 } |
4216 } | 4257 } |
4217 | 4258 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4292 * expression corresponds to one of the parameters of the function being invok
ed, then return the | 4333 * expression corresponds to one of the parameters of the function being invok
ed, then return the |
4293 * parameter element representing the parameter to which the value of this exp
ression will be | 4334 * parameter element representing the parameter to which the value of this exp
ression will be |
4294 * bound. Otherwise, return `null`. | 4335 * bound. Otherwise, return `null`. |
4295 * | 4336 * |
4296 * @return the parameter element representing the parameter to which the value
of this expression | 4337 * @return the parameter element representing the parameter to which the value
of this expression |
4297 * will be bound | 4338 * will be bound |
4298 */ | 4339 */ |
4299 ParameterElement get propagatedParameterElement { | 4340 ParameterElement get propagatedParameterElement { |
4300 ASTNode parent = this.parent; | 4341 ASTNode parent = this.parent; |
4301 if (parent is ArgumentList) { | 4342 if (parent is ArgumentList) { |
4302 return (parent as ArgumentList).getPropagatedParameterElementFor(this); | 4343 return parent.getPropagatedParameterElementFor(this); |
4303 } else if (parent is IndexExpression) { | 4344 } else if (parent is IndexExpression) { |
4304 IndexExpression indexExpression = parent as IndexExpression; | 4345 IndexExpression indexExpression = parent; |
4305 if (identical(indexExpression.index, this)) { | 4346 if (identical(indexExpression.index, this)) { |
4306 return indexExpression.propagatedParameterElementForIndex; | 4347 return indexExpression.propagatedParameterElementForIndex; |
4307 } | 4348 } |
4308 } else if (parent is BinaryExpression) { | 4349 } else if (parent is BinaryExpression) { |
4309 BinaryExpression binaryExpression = parent as BinaryExpression; | 4350 BinaryExpression binaryExpression = parent; |
4310 if (identical(binaryExpression.rightOperand, this)) { | 4351 if (identical(binaryExpression.rightOperand, this)) { |
4311 return binaryExpression.propagatedParameterElementForRightOperand; | 4352 return binaryExpression.propagatedParameterElementForRightOperand; |
4312 } | 4353 } |
4313 } else if (parent is AssignmentExpression) { | 4354 } else if (parent is AssignmentExpression) { |
4314 AssignmentExpression assignmentExpression = parent as AssignmentExpression
; | 4355 AssignmentExpression assignmentExpression = parent; |
4315 if (identical(assignmentExpression.rightHandSide, this)) { | 4356 if (identical(assignmentExpression.rightHandSide, this)) { |
4316 return assignmentExpression.propagatedParameterElementForRightHandSide; | 4357 return assignmentExpression.propagatedParameterElementForRightHandSide; |
4317 } | 4358 } |
4318 } else if (parent is PrefixExpression) { | 4359 } else if (parent is PrefixExpression) { |
4319 return (parent as PrefixExpression).propagatedParameterElementForOperand; | 4360 return parent.propagatedParameterElementForOperand; |
4320 } else if (parent is PostfixExpression) { | 4361 } else if (parent is PostfixExpression) { |
4321 return (parent as PostfixExpression).propagatedParameterElementForOperand; | 4362 return parent.propagatedParameterElementForOperand; |
4322 } | 4363 } |
4323 return null; | 4364 return null; |
4324 } | 4365 } |
4325 | 4366 |
4326 /** | 4367 /** |
4327 * If this expression is an argument to an invocation, and the AST structure h
as been resolved, | 4368 * If this expression is an argument to an invocation, and the AST structure h
as been resolved, |
4328 * and the function being invoked is known based on static type information, a
nd this expression | 4369 * and the function being invoked is known based on static type information, a
nd this expression |
4329 * corresponds to one of the parameters of the function being invoked, then re
turn the parameter | 4370 * corresponds to one of the parameters of the function being invoked, then re
turn the parameter |
4330 * element representing the parameter to which the value of this expression wi
ll be bound. | 4371 * element representing the parameter to which the value of this expression wi
ll be bound. |
4331 * Otherwise, return `null`. | 4372 * Otherwise, return `null`. |
4332 * | 4373 * |
4333 * @return the parameter element representing the parameter to which the value
of this expression | 4374 * @return the parameter element representing the parameter to which the value
of this expression |
4334 * will be bound | 4375 * will be bound |
4335 */ | 4376 */ |
4336 ParameterElement get staticParameterElement { | 4377 ParameterElement get staticParameterElement { |
4337 ASTNode parent = this.parent; | 4378 ASTNode parent = this.parent; |
4338 if (parent is ArgumentList) { | 4379 if (parent is ArgumentList) { |
4339 return (parent as ArgumentList).getStaticParameterElementFor(this); | 4380 return parent.getStaticParameterElementFor(this); |
4340 } else if (parent is IndexExpression) { | 4381 } else if (parent is IndexExpression) { |
4341 IndexExpression indexExpression = parent as IndexExpression; | 4382 IndexExpression indexExpression = parent; |
4342 if (identical(indexExpression.index, this)) { | 4383 if (identical(indexExpression.index, this)) { |
4343 return indexExpression.staticParameterElementForIndex; | 4384 return indexExpression.staticParameterElementForIndex; |
4344 } | 4385 } |
4345 } else if (parent is BinaryExpression) { | 4386 } else if (parent is BinaryExpression) { |
4346 BinaryExpression binaryExpression = parent as BinaryExpression; | 4387 BinaryExpression binaryExpression = parent; |
4347 if (identical(binaryExpression.rightOperand, this)) { | 4388 if (identical(binaryExpression.rightOperand, this)) { |
4348 return binaryExpression.staticParameterElementForRightOperand; | 4389 return binaryExpression.staticParameterElementForRightOperand; |
4349 } | 4390 } |
4350 } else if (parent is AssignmentExpression) { | 4391 } else if (parent is AssignmentExpression) { |
4351 AssignmentExpression assignmentExpression = parent as AssignmentExpression
; | 4392 AssignmentExpression assignmentExpression = parent; |
4352 if (identical(assignmentExpression.rightHandSide, this)) { | 4393 if (identical(assignmentExpression.rightHandSide, this)) { |
4353 return assignmentExpression.staticParameterElementForRightHandSide; | 4394 return assignmentExpression.staticParameterElementForRightHandSide; |
4354 } | 4395 } |
4355 } else if (parent is PrefixExpression) { | 4396 } else if (parent is PrefixExpression) { |
4356 return (parent as PrefixExpression).staticParameterElementForOperand; | 4397 return parent.staticParameterElementForOperand; |
4357 } else if (parent is PostfixExpression) { | 4398 } else if (parent is PostfixExpression) { |
4358 return (parent as PostfixExpression).staticParameterElementForOperand; | 4399 return parent.staticParameterElementForOperand; |
4359 } | 4400 } |
4360 return null; | 4401 return null; |
4361 } | 4402 } |
4362 | 4403 |
4363 /** | 4404 /** |
4364 * Return `true` if this expression is syntactically valid for the LHS of an | 4405 * Return `true` if this expression is syntactically valid for the LHS of an |
4365 * [AssignmentExpression]. | 4406 * [AssignmentExpression]. |
4366 * | 4407 * |
4367 * @return `true` if this expression matches the `assignableExpression` produc
tion | 4408 * @return `true` if this expression matches the `assignableExpression` produc
tion |
4368 */ | 4409 */ |
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6351 if (compare != 0) { | 6392 if (compare != 0) { |
6352 return compare; | 6393 return compare; |
6353 } | 6394 } |
6354 } | 6395 } |
6355 } | 6396 } |
6356 NodeList<Combinator> combinators1 = import1.combinators; | 6397 NodeList<Combinator> combinators1 = import1.combinators; |
6357 List<String> allHides1 = new List<String>(); | 6398 List<String> allHides1 = new List<String>(); |
6358 List<String> allShows1 = new List<String>(); | 6399 List<String> allShows1 = new List<String>(); |
6359 for (Combinator combinator in combinators1) { | 6400 for (Combinator combinator in combinators1) { |
6360 if (combinator is HideCombinator) { | 6401 if (combinator is HideCombinator) { |
6361 NodeList<SimpleIdentifier> hides = (combinator as HideCombinator).hidden
Names; | 6402 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; |
6362 for (SimpleIdentifier simpleIdentifier in hides) { | 6403 for (SimpleIdentifier simpleIdentifier in hides) { |
6363 allHides1.add(simpleIdentifier.name); | 6404 allHides1.add(simpleIdentifier.name); |
6364 } | 6405 } |
6365 } else { | 6406 } else { |
6366 NodeList<SimpleIdentifier> shows = (combinator as ShowCombinator).shownN
ames; | 6407 NodeList<SimpleIdentifier> shows = (combinator as ShowCombinator).shownN
ames; |
6367 for (SimpleIdentifier simpleIdentifier in shows) { | 6408 for (SimpleIdentifier simpleIdentifier in shows) { |
6368 allShows1.add(simpleIdentifier.name); | 6409 allShows1.add(simpleIdentifier.name); |
6369 } | 6410 } |
6370 } | 6411 } |
6371 } | 6412 } |
6372 NodeList<Combinator> combinators2 = import2.combinators; | 6413 NodeList<Combinator> combinators2 = import2.combinators; |
6373 List<String> allHides2 = new List<String>(); | 6414 List<String> allHides2 = new List<String>(); |
6374 List<String> allShows2 = new List<String>(); | 6415 List<String> allShows2 = new List<String>(); |
6375 for (Combinator combinator in combinators2) { | 6416 for (Combinator combinator in combinators2) { |
6376 if (combinator is HideCombinator) { | 6417 if (combinator is HideCombinator) { |
6377 NodeList<SimpleIdentifier> hides = (combinator as HideCombinator).hidden
Names; | 6418 NodeList<SimpleIdentifier> hides = combinator.hiddenNames; |
6378 for (SimpleIdentifier simpleIdentifier in hides) { | 6419 for (SimpleIdentifier simpleIdentifier in hides) { |
6379 allHides2.add(simpleIdentifier.name); | 6420 allHides2.add(simpleIdentifier.name); |
6380 } | 6421 } |
6381 } else { | 6422 } else { |
6382 NodeList<SimpleIdentifier> shows = (combinator as ShowCombinator).shownN
ames; | 6423 NodeList<SimpleIdentifier> shows = (combinator as ShowCombinator).shownN
ames; |
6383 for (SimpleIdentifier simpleIdentifier in shows) { | 6424 for (SimpleIdentifier simpleIdentifier in shows) { |
6384 allShows2.add(simpleIdentifier.name); | 6425 allShows2.add(simpleIdentifier.name); |
6385 } | 6426 } |
6386 } | 6427 } |
6387 } | 6428 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6658 * | 6699 * |
6659 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e | 6700 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e |
6660 * they mutually exclusive. In other words, it is possible for both methods to
return `true` | 6701 * they mutually exclusive. In other words, it is possible for both methods to
return `true` |
6661 * when invoked on the same node. | 6702 * when invoked on the same node. |
6662 * | 6703 * |
6663 * @return `true` if this expression is in a context where the operator '[]' w
ill be invoked | 6704 * @return `true` if this expression is in a context where the operator '[]' w
ill be invoked |
6664 */ | 6705 */ |
6665 bool inGetterContext() { | 6706 bool inGetterContext() { |
6666 ASTNode parent = this.parent; | 6707 ASTNode parent = this.parent; |
6667 if (parent is AssignmentExpression) { | 6708 if (parent is AssignmentExpression) { |
6668 AssignmentExpression assignment = parent as AssignmentExpression; | 6709 AssignmentExpression assignment = parent; |
6669 if (identical(assignment.leftHandSide, this) && identical(assignment.opera
tor.type, TokenType.EQ)) { | 6710 if (identical(assignment.leftHandSide, this) && identical(assignment.opera
tor.type, TokenType.EQ)) { |
6670 return false; | 6711 return false; |
6671 } | 6712 } |
6672 } | 6713 } |
6673 return true; | 6714 return true; |
6674 } | 6715 } |
6675 | 6716 |
6676 /** | 6717 /** |
6677 * Return `true` if this expression is computing a left-hand value. | 6718 * Return `true` if this expression is computing a left-hand value. |
6678 * | 6719 * |
6679 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e | 6720 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e |
6680 * they mutually exclusive. In other words, it is possible for both methods to
return `true` | 6721 * they mutually exclusive. In other words, it is possible for both methods to
return `true` |
6681 * when invoked on the same node. | 6722 * when invoked on the same node. |
6682 * | 6723 * |
6683 * @return `true` if this expression is in a context where the operator '[]='
will be | 6724 * @return `true` if this expression is in a context where the operator '[]='
will be |
6684 * invoked | 6725 * invoked |
6685 */ | 6726 */ |
6686 bool inSetterContext() { | 6727 bool inSetterContext() { |
6687 ASTNode parent = this.parent; | 6728 ASTNode parent = this.parent; |
6688 if (parent is PrefixExpression) { | 6729 if (parent is PrefixExpression) { |
6689 return (parent as PrefixExpression).operator.type.isIncrementOperator; | 6730 return parent.operator.type.isIncrementOperator; |
6690 } else if (parent is PostfixExpression) { | 6731 } else if (parent is PostfixExpression) { |
6691 return true; | 6732 return true; |
6692 } else if (parent is AssignmentExpression) { | 6733 } else if (parent is AssignmentExpression) { |
6693 return identical((parent as AssignmentExpression).leftHandSide, this); | 6734 return identical(parent.leftHandSide, this); |
6694 } | 6735 } |
6695 return false; | 6736 return false; |
6696 } | 6737 } |
6697 | 6738 |
6698 bool get isAssignable => true; | 6739 bool get isAssignable => true; |
6699 | 6740 |
6700 /** | 6741 /** |
6701 * Return `true` if this expression is cascaded. If it is, then the target of
this | 6742 * Return `true` if this expression is cascaded. If it is, then the target of
this |
6702 * expression is not stored locally but is stored in the nearest ancestor that
is a | 6743 * expression is not stored locally but is stored in the nearest ancestor that
is a |
6703 * [CascadeExpression]. | 6744 * [CascadeExpression]. |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8190 /** | 8231 /** |
8191 * Return the element representing the parameter being named by this expressio
n, or `null` | 8232 * Return the element representing the parameter being named by this expressio
n, or `null` |
8192 * if the AST structure has not been resolved or if there is no parameter with
the same name as | 8233 * if the AST structure has not been resolved or if there is no parameter with
the same name as |
8193 * this expression. | 8234 * this expression. |
8194 * | 8235 * |
8195 * @return the element representing the parameter being named by this expressi
on | 8236 * @return the element representing the parameter being named by this expressi
on |
8196 */ | 8237 */ |
8197 ParameterElement get element { | 8238 ParameterElement get element { |
8198 Element element = _name.label.staticElement; | 8239 Element element = _name.label.staticElement; |
8199 if (element is ParameterElement) { | 8240 if (element is ParameterElement) { |
8200 return element as ParameterElement; | 8241 return element; |
8201 } | 8242 } |
8202 return null; | 8243 return null; |
8203 } | 8244 } |
8204 | 8245 |
8205 Token get endToken => _expression.endToken; | 8246 Token get endToken => _expression.endToken; |
8206 | 8247 |
8207 /** | 8248 /** |
8208 * Return the expression with which the name is associated. | 8249 * Return the expression with which the name is associated. |
8209 * | 8250 * |
8210 * @return the expression with which the name is associated | 8251 * @return the expression with which the name is associated |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8449 * | 8490 * |
8450 * @return the documentation comment associated with this parameter | 8491 * @return the documentation comment associated with this parameter |
8451 */ | 8492 */ |
8452 Comment get documentationComment => _comment; | 8493 Comment get documentationComment => _comment; |
8453 | 8494 |
8454 SimpleIdentifier get identifier => _identifier; | 8495 SimpleIdentifier get identifier => _identifier; |
8455 | 8496 |
8456 ParameterKind get kind { | 8497 ParameterKind get kind { |
8457 ASTNode parent = this.parent; | 8498 ASTNode parent = this.parent; |
8458 if (parent is DefaultFormalParameter) { | 8499 if (parent is DefaultFormalParameter) { |
8459 return (parent as DefaultFormalParameter).kind; | 8500 return parent.kind; |
8460 } | 8501 } |
8461 return ParameterKind.REQUIRED; | 8502 return ParameterKind.REQUIRED; |
8462 } | 8503 } |
8463 | 8504 |
8464 /** | 8505 /** |
8465 * Return the annotations associated with this parameter. | 8506 * Return the annotations associated with this parameter. |
8466 * | 8507 * |
8467 * @return the annotations associated with this parameter | 8508 * @return the annotations associated with this parameter |
8468 */ | 8509 */ |
8469 NodeList<Annotation> get metadata => _metadata; | 8510 NodeList<Annotation> get metadata => _metadata; |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9788 Element get staticElement => _staticElement; | 9829 Element get staticElement => _staticElement; |
9789 | 9830 |
9790 /** | 9831 /** |
9791 * Return `true` if this identifier is the name being declared in a declaratio
n. | 9832 * Return `true` if this identifier is the name being declared in a declaratio
n. |
9792 * | 9833 * |
9793 * @return `true` if this identifier is the name being declared in a declarati
on | 9834 * @return `true` if this identifier is the name being declared in a declarati
on |
9794 */ | 9835 */ |
9795 bool inDeclarationContext() { | 9836 bool inDeclarationContext() { |
9796 ASTNode parent = this.parent; | 9837 ASTNode parent = this.parent; |
9797 if (parent is CatchClause) { | 9838 if (parent is CatchClause) { |
9798 CatchClause clause = parent as CatchClause; | 9839 CatchClause clause = parent; |
9799 return identical(this, clause.exceptionParameter) || identical(this, claus
e.stackTraceParameter); | 9840 return identical(this, clause.exceptionParameter) || identical(this, claus
e.stackTraceParameter); |
9800 } else if (parent is ClassDeclaration) { | 9841 } else if (parent is ClassDeclaration) { |
9801 return identical(this, (parent as ClassDeclaration).name); | 9842 return identical(this, parent.name); |
9802 } else if (parent is ClassTypeAlias) { | 9843 } else if (parent is ClassTypeAlias) { |
9803 return identical(this, (parent as ClassTypeAlias).name); | 9844 return identical(this, parent.name); |
9804 } else if (parent is ConstructorDeclaration) { | 9845 } else if (parent is ConstructorDeclaration) { |
9805 return identical(this, (parent as ConstructorDeclaration).name); | 9846 return identical(this, parent.name); |
9806 } else if (parent is DeclaredIdentifier) { | 9847 } else if (parent is DeclaredIdentifier) { |
9807 return identical(this, (parent as DeclaredIdentifier).identifier); | 9848 return identical(this, parent.identifier); |
9808 } else if (parent is FunctionDeclaration) { | 9849 } else if (parent is FunctionDeclaration) { |
9809 return identical(this, (parent as FunctionDeclaration).name); | 9850 return identical(this, parent.name); |
9810 } else if (parent is FunctionTypeAlias) { | 9851 } else if (parent is FunctionTypeAlias) { |
9811 return identical(this, (parent as FunctionTypeAlias).name); | 9852 return identical(this, parent.name); |
9812 } else if (parent is Label) { | 9853 } else if (parent is Label) { |
9813 return identical(this, (parent as Label).label) && (parent.parent is Label
edStatement); | 9854 return identical(this, parent.label) && (parent.parent is LabeledStatement
); |
9814 } else if (parent is MethodDeclaration) { | 9855 } else if (parent is MethodDeclaration) { |
9815 return identical(this, (parent as MethodDeclaration).name); | 9856 return identical(this, parent.name); |
9816 } else if (parent is FunctionTypedFormalParameter || parent is SimpleFormalP
arameter) { | 9857 } else if (parent is FunctionTypedFormalParameter || parent is SimpleFormalP
arameter) { |
9817 return identical(this, (parent as NormalFormalParameter).identifier); | 9858 return identical(this, (parent as NormalFormalParameter).identifier); |
9818 } else if (parent is TypeParameter) { | 9859 } else if (parent is TypeParameter) { |
9819 return identical(this, (parent as TypeParameter).name); | 9860 return identical(this, parent.name); |
9820 } else if (parent is VariableDeclaration) { | 9861 } else if (parent is VariableDeclaration) { |
9821 return identical(this, (parent as VariableDeclaration).name); | 9862 return identical(this, parent.name); |
9822 } | 9863 } |
9823 return false; | 9864 return false; |
9824 } | 9865 } |
9825 | 9866 |
9826 /** | 9867 /** |
9827 * Return `true` if this expression is computing a right-hand value. | 9868 * Return `true` if this expression is computing a right-hand value. |
9828 * | 9869 * |
9829 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e | 9870 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar
e |
9830 * they mutually exclusive. In other words, it is possible for both methods to
return `true` | 9871 * they mutually exclusive. In other words, it is possible for both methods to
return `true` |
9831 * when invoked on the same node. | 9872 * when invoked on the same node. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9944 * identifier, or `null` if it is not appropriate. | 9985 * identifier, or `null` if it is not appropriate. |
9945 * | 9986 * |
9946 * @param element the element to be associated with this identifier | 9987 * @param element the element to be associated with this identifier |
9947 * @return the element to be associated with this identifier | 9988 * @return the element to be associated with this identifier |
9948 */ | 9989 */ |
9949 Element validateElement2(Element element) { | 9990 Element validateElement2(Element element) { |
9950 if (element == null) { | 9991 if (element == null) { |
9951 return null; | 9992 return null; |
9952 } | 9993 } |
9953 ASTNode parent = this.parent; | 9994 ASTNode parent = this.parent; |
9954 if (parent is ClassDeclaration && identical((parent as ClassDeclaration).nam
e, this)) { | 9995 if (parent is ClassDeclaration && identical(parent.name, this)) { |
9955 return validateElement(parent, ClassElement, element); | 9996 return validateElement(parent, ClassElement, element); |
9956 } else if (parent is ClassTypeAlias && identical((parent as ClassTypeAlias).
name, this)) { | 9997 } else if (parent is ClassTypeAlias && identical(parent.name, this)) { |
9957 return validateElement(parent, ClassElement, element); | 9998 return validateElement(parent, ClassElement, element); |
9958 } else if (parent is DeclaredIdentifier && identical((parent as DeclaredIden
tifier).identifier, this)) { | 9999 } else if (parent is DeclaredIdentifier && identical(parent.identifier, this
)) { |
9959 return validateElement(parent, LocalVariableElement, element); | 10000 return validateElement(parent, LocalVariableElement, element); |
9960 } else if (parent is FormalParameter && identical((parent as FormalParameter
).identifier, this)) { | 10001 } else if (parent is FormalParameter && identical(parent.identifier, this))
{ |
9961 return validateElement(parent, ParameterElement, element); | 10002 return validateElement(parent, ParameterElement, element); |
9962 } else if (parent is FunctionDeclaration && identical((parent as FunctionDec
laration).name, this)) { | 10003 } else if (parent is FunctionDeclaration && identical(parent.name, this)) { |
9963 return validateElement(parent, ExecutableElement, element); | 10004 return validateElement(parent, ExecutableElement, element); |
9964 } else if (parent is FunctionTypeAlias && identical((parent as FunctionTypeA
lias).name, this)) { | 10005 } else if (parent is FunctionTypeAlias && identical(parent.name, this)) { |
9965 return validateElement(parent, FunctionTypeAliasElement, element); | 10006 return validateElement(parent, FunctionTypeAliasElement, element); |
9966 } else if (parent is MethodDeclaration && identical((parent as MethodDeclara
tion).name, this)) { | 10007 } else if (parent is MethodDeclaration && identical(parent.name, this)) { |
9967 return validateElement(parent, ExecutableElement, element); | 10008 return validateElement(parent, ExecutableElement, element); |
9968 } else if (parent is TypeParameter && identical((parent as TypeParameter).na
me, this)) { | 10009 } else if (parent is TypeParameter && identical(parent.name, this)) { |
9969 return validateElement(parent, TypeParameterElement, element); | 10010 return validateElement(parent, TypeParameterElement, element); |
9970 } else if (parent is VariableDeclaration && identical((parent as VariableDec
laration).name, this)) { | 10011 } else if (parent is VariableDeclaration && identical(parent.name, this)) { |
9971 return validateElement(parent, VariableElement, element); | 10012 return validateElement(parent, VariableElement, element); |
9972 } | 10013 } |
9973 return element; | 10014 return element; |
9974 } | 10015 } |
9975 } | 10016 } |
9976 | 10017 |
9977 /** | 10018 /** |
9978 * Instances of the class `SimpleStringLiteral` represent a string literal expre
ssion that | 10019 * Instances of the class `SimpleStringLiteral` represent a string literal expre
ssion that |
9979 * does not contain any interpolations. | 10020 * does not contain any interpolations. |
9980 * | 10021 * |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11411 /** | 11452 /** |
11412 * This overridden implementation of getDocumentationComment() looks in the gr
andparent node for | 11453 * This overridden implementation of getDocumentationComment() looks in the gr
andparent node for |
11413 * dartdoc comments if no documentation is specifically available on the node. | 11454 * dartdoc comments if no documentation is specifically available on the node. |
11414 */ | 11455 */ |
11415 Comment get documentationComment { | 11456 Comment get documentationComment { |
11416 Comment comment = super.documentationComment; | 11457 Comment comment = super.documentationComment; |
11417 if (comment == null) { | 11458 if (comment == null) { |
11418 if (parent != null && parent.parent != null) { | 11459 if (parent != null && parent.parent != null) { |
11419 ASTNode node = parent.parent; | 11460 ASTNode node = parent.parent; |
11420 if (node is AnnotatedNode) { | 11461 if (node is AnnotatedNode) { |
11421 return (node as AnnotatedNode).documentationComment; | 11462 return node.documentationComment; |
11422 } | 11463 } |
11423 } | 11464 } |
11424 } | 11465 } |
11425 return comment; | 11466 return comment; |
11426 } | 11467 } |
11427 | 11468 |
11428 VariableElement get element => _name != null ? (_name.staticElement as Variabl
eElement) : null; | 11469 VariableElement get element => _name != null ? (_name.staticElement as Variabl
eElement) : null; |
11429 | 11470 |
11430 Token get endToken { | 11471 Token get endToken { |
11431 if (_initializer != null) { | 11472 if (_initializer != null) { |
(...skipping 17 matching lines...) Expand all Loading... |
11449 */ | 11490 */ |
11450 SimpleIdentifier get name => _name; | 11491 SimpleIdentifier get name => _name; |
11451 | 11492 |
11452 /** | 11493 /** |
11453 * Return `true` if this variable was declared with the 'const' modifier. | 11494 * Return `true` if this variable was declared with the 'const' modifier. |
11454 * | 11495 * |
11455 * @return `true` if this variable was declared with the 'const' modifier | 11496 * @return `true` if this variable was declared with the 'const' modifier |
11456 */ | 11497 */ |
11457 bool get isConst { | 11498 bool get isConst { |
11458 ASTNode parent = this.parent; | 11499 ASTNode parent = this.parent; |
11459 return parent is VariableDeclarationList && (parent as VariableDeclarationLi
st).isConst; | 11500 return parent is VariableDeclarationList && parent.isConst; |
11460 } | 11501 } |
11461 | 11502 |
11462 /** | 11503 /** |
11463 * Return `true` if this variable was declared with the 'final' modifier. Vari
ables that are | 11504 * Return `true` if this variable was declared with the 'final' modifier. Vari
ables that are |
11464 * declared with the 'const' modifier will return `false` even though they are
implicitly | 11505 * declared with the 'const' modifier will return `false` even though they are
implicitly |
11465 * final. | 11506 * final. |
11466 * | 11507 * |
11467 * @return `true` if this variable was declared with the 'final' modifier | 11508 * @return `true` if this variable was declared with the 'final' modifier |
11468 */ | 11509 */ |
11469 bool get isFinal { | 11510 bool get isFinal { |
11470 ASTNode parent = this.parent; | 11511 ASTNode parent = this.parent; |
11471 return parent is VariableDeclarationList && (parent as VariableDeclarationLi
st).isFinal; | 11512 return parent is VariableDeclarationList && parent.isFinal; |
11472 } | 11513 } |
11473 | 11514 |
11474 /** | 11515 /** |
11475 * Set the expression used to compute the initial value for the variable to th
e given expression. | 11516 * Set the expression used to compute the initial value for the variable to th
e given expression. |
11476 * | 11517 * |
11477 * @param initializer the expression used to compute the initial value for the
variable | 11518 * @param initializer the expression used to compute the initial value for the
variable |
11478 */ | 11519 */ |
11479 void set initializer(Expression initializer) { | 11520 void set initializer(Expression initializer) { |
11480 this._initializer = becomeParentOf(initializer); | 11521 this._initializer = becomeParentOf(initializer); |
11481 } | 11522 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11955 if (identical(leftOperand, NOT_A_CONSTANT)) { | 11996 if (identical(leftOperand, NOT_A_CONSTANT)) { |
11956 return leftOperand; | 11997 return leftOperand; |
11957 } | 11998 } |
11958 Object rightOperand = node.rightOperand.accept(this); | 11999 Object rightOperand = node.rightOperand.accept(this); |
11959 if (identical(rightOperand, NOT_A_CONSTANT)) { | 12000 if (identical(rightOperand, NOT_A_CONSTANT)) { |
11960 return rightOperand; | 12001 return rightOperand; |
11961 } | 12002 } |
11962 while (true) { | 12003 while (true) { |
11963 if (node.operator.type == TokenType.AMPERSAND) { | 12004 if (node.operator.type == TokenType.AMPERSAND) { |
11964 if (leftOperand is int && rightOperand is int) { | 12005 if (leftOperand is int && rightOperand is int) { |
11965 return (leftOperand as int) & (rightOperand as int); | 12006 return leftOperand & rightOperand; |
11966 } | 12007 } |
11967 } else if (node.operator.type == TokenType.AMPERSAND_AMPERSAND) { | 12008 } else if (node.operator.type == TokenType.AMPERSAND_AMPERSAND) { |
11968 if (leftOperand is bool && rightOperand is bool) { | 12009 if (leftOperand is bool && rightOperand is bool) { |
11969 return (leftOperand as bool) && (rightOperand as bool); | 12010 return leftOperand && rightOperand; |
11970 } | 12011 } |
11971 } else if (node.operator.type == TokenType.BANG_EQ) { | 12012 } else if (node.operator.type == TokenType.BANG_EQ) { |
11972 if (leftOperand is bool && rightOperand is bool) { | 12013 if (leftOperand is bool && rightOperand is bool) { |
11973 return (leftOperand as bool) != (rightOperand as bool); | 12014 return leftOperand != rightOperand; |
11974 } else if (leftOperand is int && rightOperand is int) { | 12015 } else if (leftOperand is int && rightOperand is int) { |
11975 return (leftOperand as int) != rightOperand; | 12016 return leftOperand != rightOperand; |
11976 } else if (leftOperand is double && rightOperand is double) { | 12017 } else if (leftOperand is double && rightOperand is double) { |
11977 return (leftOperand as double) != rightOperand; | 12018 return leftOperand != rightOperand; |
11978 } else if (leftOperand is String && rightOperand is String) { | 12019 } else if (leftOperand is String && rightOperand is String) { |
11979 return (leftOperand as String) != rightOperand; | 12020 return leftOperand != rightOperand; |
11980 } | 12021 } |
11981 } else if (node.operator.type == TokenType.BAR) { | 12022 } else if (node.operator.type == TokenType.BAR) { |
11982 if (leftOperand is int && rightOperand is int) { | 12023 if (leftOperand is int && rightOperand is int) { |
11983 return (leftOperand as int) | (rightOperand as int); | 12024 return leftOperand | rightOperand; |
11984 } | 12025 } |
11985 } else if (node.operator.type == TokenType.BAR_BAR) { | 12026 } else if (node.operator.type == TokenType.BAR_BAR) { |
11986 if (leftOperand is bool && rightOperand is bool) { | 12027 if (leftOperand is bool && rightOperand is bool) { |
11987 return (leftOperand as bool) || (rightOperand as bool); | 12028 return leftOperand || rightOperand; |
11988 } | 12029 } |
11989 } else if (node.operator.type == TokenType.CARET) { | 12030 } else if (node.operator.type == TokenType.CARET) { |
11990 if (leftOperand is int && rightOperand is int) { | 12031 if (leftOperand is int && rightOperand is int) { |
11991 return (leftOperand as int) ^ (rightOperand as int); | 12032 return leftOperand ^ rightOperand; |
11992 } | 12033 } |
11993 } else if (node.operator.type == TokenType.EQ_EQ) { | 12034 } else if (node.operator.type == TokenType.EQ_EQ) { |
11994 if (leftOperand is bool && rightOperand is bool) { | 12035 if (leftOperand is bool && rightOperand is bool) { |
11995 return identical(leftOperand as bool, rightOperand as bool); | 12036 return identical(leftOperand, rightOperand); |
11996 } else if (leftOperand is int && rightOperand is int) { | 12037 } else if (leftOperand is int && rightOperand is int) { |
11997 return (leftOperand as int) == rightOperand; | 12038 return leftOperand == rightOperand; |
11998 } else if (leftOperand is double && rightOperand is double) { | 12039 } else if (leftOperand is double && rightOperand is double) { |
11999 return (leftOperand as double) == rightOperand; | 12040 return leftOperand == rightOperand; |
12000 } else if (leftOperand is String && rightOperand is String) { | 12041 } else if (leftOperand is String && rightOperand is String) { |
12001 return (leftOperand as String) == rightOperand; | 12042 return leftOperand == rightOperand; |
12002 } | 12043 } |
12003 } else if (node.operator.type == TokenType.GT) { | 12044 } else if (node.operator.type == TokenType.GT) { |
12004 if (leftOperand is int && rightOperand is int) { | 12045 if (leftOperand is int && rightOperand is int) { |
12005 return (leftOperand as int).compareTo(rightOperand as int) > 0; | 12046 return leftOperand.compareTo(rightOperand) > 0; |
12006 } else if (leftOperand is double && rightOperand is double) { | 12047 } else if (leftOperand is double && rightOperand is double) { |
12007 return (leftOperand as double).compareTo(rightOperand as double) > 0; | 12048 return leftOperand.compareTo(rightOperand) > 0; |
12008 } | 12049 } |
12009 } else if (node.operator.type == TokenType.GT_EQ) { | 12050 } else if (node.operator.type == TokenType.GT_EQ) { |
12010 if (leftOperand is int && rightOperand is int) { | 12051 if (leftOperand is int && rightOperand is int) { |
12011 return (leftOperand as int).compareTo(rightOperand as int) >= 0; | 12052 return leftOperand.compareTo(rightOperand) >= 0; |
12012 } else if (leftOperand is double && rightOperand is double) { | 12053 } else if (leftOperand is double && rightOperand is double) { |
12013 return (leftOperand as double).compareTo(rightOperand as double) >= 0; | 12054 return leftOperand.compareTo(rightOperand) >= 0; |
12014 } | 12055 } |
12015 } else if (node.operator.type == TokenType.GT_GT) { | 12056 } else if (node.operator.type == TokenType.GT_GT) { |
12016 if (leftOperand is int && rightOperand is int) { | 12057 if (leftOperand is int && rightOperand is int) { |
12017 return (leftOperand as int) >> (rightOperand as int); | 12058 return leftOperand >> rightOperand; |
12018 } | 12059 } |
12019 } else if (node.operator.type == TokenType.LT) { | 12060 } else if (node.operator.type == TokenType.LT) { |
12020 if (leftOperand is int && rightOperand is int) { | 12061 if (leftOperand is int && rightOperand is int) { |
12021 return (leftOperand as int).compareTo(rightOperand as int) < 0; | 12062 return leftOperand.compareTo(rightOperand) < 0; |
12022 } else if (leftOperand is double && rightOperand is double) { | 12063 } else if (leftOperand is double && rightOperand is double) { |
12023 return (leftOperand as double).compareTo(rightOperand as double) < 0; | 12064 return leftOperand.compareTo(rightOperand) < 0; |
12024 } | 12065 } |
12025 } else if (node.operator.type == TokenType.LT_EQ) { | 12066 } else if (node.operator.type == TokenType.LT_EQ) { |
12026 if (leftOperand is int && rightOperand is int) { | 12067 if (leftOperand is int && rightOperand is int) { |
12027 return (leftOperand as int).compareTo(rightOperand as int) <= 0; | 12068 return leftOperand.compareTo(rightOperand) <= 0; |
12028 } else if (leftOperand is double && rightOperand is double) { | 12069 } else if (leftOperand is double && rightOperand is double) { |
12029 return (leftOperand as double).compareTo(rightOperand as double) <= 0; | 12070 return leftOperand.compareTo(rightOperand) <= 0; |
12030 } | 12071 } |
12031 } else if (node.operator.type == TokenType.LT_LT) { | 12072 } else if (node.operator.type == TokenType.LT_LT) { |
12032 if (leftOperand is int && rightOperand is int) { | 12073 if (leftOperand is int && rightOperand is int) { |
12033 return (leftOperand as int) << (rightOperand as int); | 12074 return leftOperand << rightOperand; |
12034 } | 12075 } |
12035 } else if (node.operator.type == TokenType.MINUS) { | 12076 } else if (node.operator.type == TokenType.MINUS) { |
12036 if (leftOperand is int && rightOperand is int) { | 12077 if (leftOperand is int && rightOperand is int) { |
12037 return (leftOperand as int) - (rightOperand as int); | 12078 return leftOperand - rightOperand; |
12038 } else if (leftOperand is double && rightOperand is double) { | 12079 } else if (leftOperand is double && rightOperand is double) { |
12039 return (leftOperand as double) - (rightOperand as double); | 12080 return leftOperand - rightOperand; |
12040 } | 12081 } |
12041 } else if (node.operator.type == TokenType.PERCENT) { | 12082 } else if (node.operator.type == TokenType.PERCENT) { |
12042 if (leftOperand is int && rightOperand is int) { | 12083 if (leftOperand is int && rightOperand is int) { |
12043 return (leftOperand as int).remainder(rightOperand as int); | 12084 return leftOperand.remainder(rightOperand); |
12044 } else if (leftOperand is double && rightOperand is double) { | 12085 } else if (leftOperand is double && rightOperand is double) { |
12045 return (leftOperand as double) % (rightOperand as double); | 12086 return leftOperand % rightOperand; |
12046 } | 12087 } |
12047 } else if (node.operator.type == TokenType.PLUS) { | 12088 } else if (node.operator.type == TokenType.PLUS) { |
12048 if (leftOperand is int && rightOperand is int) { | 12089 if (leftOperand is int && rightOperand is int) { |
12049 return (leftOperand as int) + (rightOperand as int); | 12090 return leftOperand + rightOperand; |
12050 } else if (leftOperand is double && rightOperand is double) { | 12091 } else if (leftOperand is double && rightOperand is double) { |
12051 return (leftOperand as double) + (rightOperand as double); | 12092 return leftOperand + rightOperand; |
12052 } | 12093 } |
12053 } else if (node.operator.type == TokenType.STAR) { | 12094 } else if (node.operator.type == TokenType.STAR) { |
12054 if (leftOperand is int && rightOperand is int) { | 12095 if (leftOperand is int && rightOperand is int) { |
12055 return (leftOperand as int) * (rightOperand as int); | 12096 return leftOperand * rightOperand; |
12056 } else if (leftOperand is double && rightOperand is double) { | 12097 } else if (leftOperand is double && rightOperand is double) { |
12057 return (leftOperand as double) * (rightOperand as double); | 12098 return leftOperand * rightOperand; |
12058 } | 12099 } |
12059 } else if (node.operator.type == TokenType.SLASH) { | 12100 } else if (node.operator.type == TokenType.SLASH) { |
12060 if (leftOperand is int && rightOperand is int) { | 12101 if (leftOperand is int && rightOperand is int) { |
12061 if (rightOperand != 0) { | 12102 if (rightOperand != 0) { |
12062 return (leftOperand as int) ~/ (rightOperand as int); | 12103 return leftOperand ~/ rightOperand; |
12063 } else { | 12104 } else { |
12064 return (leftOperand as int).toDouble() / (rightOperand as int).toDou
ble(); | 12105 return leftOperand.toDouble() / rightOperand.toDouble(); |
12065 } | 12106 } |
12066 } else if (leftOperand is double && rightOperand is double) { | 12107 } else if (leftOperand is double && rightOperand is double) { |
12067 return (leftOperand as double) / (rightOperand as double); | 12108 return leftOperand / rightOperand; |
12068 } | 12109 } |
12069 } else if (node.operator.type == TokenType.TILDE_SLASH) { | 12110 } else if (node.operator.type == TokenType.TILDE_SLASH) { |
12070 if (leftOperand is int && rightOperand is int) { | 12111 if (leftOperand is int && rightOperand is int) { |
12071 if (rightOperand != 0) { | 12112 if (rightOperand != 0) { |
12072 return (leftOperand as int) ~/ (rightOperand as int); | 12113 return leftOperand ~/ rightOperand; |
12073 } else { | 12114 } else { |
12074 return 0; | 12115 return 0; |
12075 } | 12116 } |
12076 } else if (leftOperand is double && rightOperand is double) { | 12117 } else if (leftOperand is double && rightOperand is double) { |
12077 return (leftOperand as double) ~/ (rightOperand as double); | 12118 return leftOperand ~/ rightOperand; |
12078 } | 12119 } |
12079 } | 12120 } |
12080 break; | 12121 break; |
12081 } | 12122 } |
12082 return visitExpression(node); | 12123 return visitExpression(node); |
12083 } | 12124 } |
12084 | 12125 |
12085 Object visitBooleanLiteral(BooleanLiteral node) => node.value ? true : false; | 12126 Object visitBooleanLiteral(BooleanLiteral node) => node.value ? true : false; |
12086 | 12127 |
12087 Object visitDoubleLiteral(DoubleLiteral node) => node.value; | 12128 Object visitDoubleLiteral(DoubleLiteral node) => node.value; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12140 } | 12181 } |
12141 while (true) { | 12182 while (true) { |
12142 if (node.operator.type == TokenType.BANG) { | 12183 if (node.operator.type == TokenType.BANG) { |
12143 if (identical(operand, true)) { | 12184 if (identical(operand, true)) { |
12144 return false; | 12185 return false; |
12145 } else if (identical(operand, false)) { | 12186 } else if (identical(operand, false)) { |
12146 return true; | 12187 return true; |
12147 } | 12188 } |
12148 } else if (node.operator.type == TokenType.TILDE) { | 12189 } else if (node.operator.type == TokenType.TILDE) { |
12149 if (operand is int) { | 12190 if (operand is int) { |
12150 return ~(operand as int); | 12191 return ~operand; |
12151 } | 12192 } |
12152 } else if (node.operator.type == TokenType.MINUS) { | 12193 } else if (node.operator.type == TokenType.MINUS) { |
12153 if (operand == null) { | 12194 if (operand == null) { |
12154 return null; | 12195 return null; |
12155 } else if (operand is int) { | 12196 } else if (operand is int) { |
12156 return -(operand as int); | 12197 return -operand; |
12157 } else if (operand is double) { | 12198 } else if (operand is double) { |
12158 return -(operand as double); | 12199 return -operand; |
12159 } | 12200 } |
12160 } | 12201 } |
12161 break; | 12202 break; |
12162 } | 12203 } |
12163 return NOT_A_CONSTANT; | 12204 return NOT_A_CONSTANT; |
12164 } | 12205 } |
12165 | 12206 |
12166 Object visitPropertyAccess(PropertyAccess node) => getConstantValue(null); | 12207 Object visitPropertyAccess(PropertyAccess node) => getConstantValue(null); |
12167 | 12208 |
12168 Object visitSimpleIdentifier(SimpleIdentifier node) => getConstantValue(null); | 12209 Object visitSimpleIdentifier(SimpleIdentifier node) => getConstantValue(null); |
(...skipping 24 matching lines...) Expand all Loading... |
12193 } | 12234 } |
12194 | 12235 |
12195 /** | 12236 /** |
12196 * Return the constant value of the static constant represented by the given e
lement. | 12237 * Return the constant value of the static constant represented by the given e
lement. |
12197 * | 12238 * |
12198 * @param element the element whose value is to be returned | 12239 * @param element the element whose value is to be returned |
12199 * @return the constant value of the static constant | 12240 * @return the constant value of the static constant |
12200 */ | 12241 */ |
12201 Object getConstantValue(Element element) { | 12242 Object getConstantValue(Element element) { |
12202 if (element is FieldElement) { | 12243 if (element is FieldElement) { |
12203 FieldElement field = element as FieldElement; | 12244 FieldElement field = element; |
12204 if (field.isStatic && field.isConst) { | 12245 if (field.isStatic && field.isConst) { |
12205 } | 12246 } |
12206 } | 12247 } |
12207 return NOT_A_CONSTANT; | 12248 return NOT_A_CONSTANT; |
12208 } | 12249 } |
12209 } | 12250 } |
12210 | 12251 |
12211 /** | 12252 /** |
12212 * Instances of the class `ElementLocator` locate the [Element] | 12253 * Instances of the class `ElementLocator` locate the [Element] |
12213 * associated with a given [ASTNode]. | 12254 * associated with a given [ASTNode]. |
12214 * | 12255 * |
12215 * @coverage dart.engine.ast | 12256 * @coverage dart.engine.ast |
12216 */ | 12257 */ |
12217 class ElementLocator { | 12258 class ElementLocator { |
12218 /** | 12259 /** |
12219 * Locate the [Element] associated with the given [ASTNode]. | 12260 * Locate the [Element] associated with the given [ASTNode]. |
12220 * | 12261 * |
12221 * @param node the node (not `null`) | 12262 * @param node the node (not `null`) |
12222 * @return the associated element, or `null` if none is found | 12263 * @return the associated element, or `null` if none is found |
12223 */ | 12264 */ |
12224 static Element locate(ASTNode node) { | 12265 static Element locate(ASTNode node) { |
12225 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); | 12266 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); |
12226 return node.accept(mapper); | 12267 return node.accept(mapper); |
12227 } | 12268 } |
| 12269 |
| 12270 /** |
| 12271 * Locate the [Element] associated with the given [ASTNode] and offset. |
| 12272 * |
| 12273 * @param node the node (not `null`) |
| 12274 * @param offset the offset relative to source |
| 12275 * @return the associated element, or `null` if none is found |
| 12276 */ |
| 12277 static Element locate2(ASTNode node, int offset) { |
| 12278 { |
| 12279 Element nodeElement = locate(node); |
| 12280 if (nodeElement != null) { |
| 12281 return nodeElement; |
| 12282 } |
| 12283 } |
| 12284 { |
| 12285 Element element = null; |
| 12286 if (element != null) { |
| 12287 return element; |
| 12288 } |
| 12289 } |
| 12290 return null; |
| 12291 } |
12228 } | 12292 } |
12229 | 12293 |
12230 /** | 12294 /** |
12231 * Visitor that maps nodes to elements. | 12295 * Visitor that maps nodes to elements. |
12232 */ | 12296 */ |
12233 class ElementLocator_ElementMapper extends GeneralizingASTVisitor<Element> { | 12297 class ElementLocator_ElementMapper extends GeneralizingASTVisitor<Element> { |
12234 Element visitAssignmentExpression(AssignmentExpression node) => node.bestEleme
nt; | 12298 Element visitAssignmentExpression(AssignmentExpression node) => node.bestEleme
nt; |
12235 | 12299 |
12236 Element visitBinaryExpression(BinaryExpression node) => node.bestElement; | 12300 Element visitBinaryExpression(BinaryExpression node) => node.bestElement; |
12237 | 12301 |
12238 Element visitClassDeclaration(ClassDeclaration node) => node.element; | 12302 Element visitClassDeclaration(ClassDeclaration node) => node.element; |
12239 | 12303 |
12240 Element visitCompilationUnit(CompilationUnit node) => node.element; | 12304 Element visitCompilationUnit(CompilationUnit node) => node.element; |
12241 | 12305 |
12242 Element visitConstructorDeclaration(ConstructorDeclaration node) => node.eleme
nt; | 12306 Element visitConstructorDeclaration(ConstructorDeclaration node) => node.eleme
nt; |
12243 | 12307 |
12244 Element visitFunctionDeclaration(FunctionDeclaration node) => node.element; | 12308 Element visitFunctionDeclaration(FunctionDeclaration node) => node.element; |
12245 | 12309 |
12246 Element visitIdentifier(Identifier node) { | 12310 Element visitIdentifier(Identifier node) { |
12247 ASTNode parent = node.parent; | 12311 ASTNode parent = node.parent; |
12248 if (parent is ConstructorDeclaration) { | 12312 if (parent is ConstructorDeclaration) { |
12249 ConstructorDeclaration decl = parent as ConstructorDeclaration; | 12313 ConstructorDeclaration decl = parent; |
12250 Identifier returnType = decl.returnType; | 12314 Identifier returnType = decl.returnType; |
12251 if (identical(returnType, node)) { | 12315 if (identical(returnType, node)) { |
12252 SimpleIdentifier name = decl.name; | 12316 SimpleIdentifier name = decl.name; |
12253 if (name != null) { | 12317 if (name != null) { |
12254 return name.bestElement; | 12318 return name.bestElement; |
12255 } | 12319 } |
12256 Element element = node.bestElement; | 12320 Element element = node.bestElement; |
12257 if (element is ClassElement) { | 12321 if (element is ClassElement) { |
12258 return (element as ClassElement).unnamedConstructor; | 12322 return element.unnamedConstructor; |
12259 } | 12323 } |
12260 } | 12324 } |
12261 } | 12325 } |
12262 if (parent is LibraryIdentifier) { | 12326 if (parent is LibraryIdentifier) { |
12263 ASTNode grandParent = (parent as LibraryIdentifier).parent; | 12327 ASTNode grandParent = parent.parent; |
12264 if (grandParent is PartOfDirective) { | 12328 if (grandParent is PartOfDirective) { |
12265 Element element = (grandParent as PartOfDirective).element; | 12329 Element element = grandParent.element; |
12266 if (element is LibraryElement) { | 12330 if (element is LibraryElement) { |
12267 return (element as LibraryElement).definingCompilationUnit; | 12331 return element.definingCompilationUnit; |
12268 } | 12332 } |
12269 } | 12333 } |
12270 } | 12334 } |
12271 Element element = node.bestElement; | 12335 Element element = node.bestElement; |
12272 if (element == null) { | 12336 if (element == null) { |
12273 element = node.staticElement; | 12337 element = node.staticElement; |
12274 } | 12338 } |
12275 return element; | 12339 return element; |
12276 } | 12340 } |
12277 | 12341 |
(...skipping 11 matching lines...) Expand all Loading... |
12289 | 12353 |
12290 Element visitPostfixExpression(PostfixExpression node) => node.bestElement; | 12354 Element visitPostfixExpression(PostfixExpression node) => node.bestElement; |
12291 | 12355 |
12292 Element visitPrefixedIdentifier(PrefixedIdentifier node) => node.bestElement; | 12356 Element visitPrefixedIdentifier(PrefixedIdentifier node) => node.bestElement; |
12293 | 12357 |
12294 Element visitPrefixExpression(PrefixExpression node) => node.bestElement; | 12358 Element visitPrefixExpression(PrefixExpression node) => node.bestElement; |
12295 | 12359 |
12296 Element visitStringLiteral(StringLiteral node) { | 12360 Element visitStringLiteral(StringLiteral node) { |
12297 ASTNode parent = node.parent; | 12361 ASTNode parent = node.parent; |
12298 if (parent is UriBasedDirective) { | 12362 if (parent is UriBasedDirective) { |
12299 return (parent as UriBasedDirective).uriElement; | 12363 return parent.uriElement; |
12300 } | 12364 } |
12301 return null; | 12365 return null; |
12302 } | 12366 } |
12303 | 12367 |
12304 Element visitVariableDeclaration(VariableDeclaration node) => node.element; | 12368 Element visitVariableDeclaration(VariableDeclaration node) => node.element; |
12305 } | 12369 } |
12306 | 12370 |
12307 /** | 12371 /** |
12308 * Instances of the class `GeneralizingASTVisitor` implement an AST visitor that
will | 12372 * Instances of the class `GeneralizingASTVisitor` implement an AST visitor that
will |
12309 * recursively visit all of the nodes in an AST structure (like instances of the
class | 12373 * recursively visit all of the nodes in an AST structure (like instances of the
class |
(...skipping 3680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15990 | 16054 |
15991 WhileStatement visitWhileStatement(WhileStatement node) => new WhileStatement(
map(node.keyword), map(node.leftParenthesis), clone4(node.condition), map(node.r
ightParenthesis), clone4(node.body)); | 16055 WhileStatement visitWhileStatement(WhileStatement node) => new WhileStatement(
map(node.keyword), map(node.leftParenthesis), clone4(node.condition), map(node.r
ightParenthesis), clone4(node.body)); |
15992 | 16056 |
15993 WithClause visitWithClause(WithClause node) => new WithClause(map(node.withKey
word), clone5(node.mixinTypes)); | 16057 WithClause visitWithClause(WithClause node) => new WithClause(map(node.withKey
word), clone5(node.mixinTypes)); |
15994 | 16058 |
15995 ASTNode clone4(ASTNode node) { | 16059 ASTNode clone4(ASTNode node) { |
15996 if (node == null) { | 16060 if (node == null) { |
15997 return null; | 16061 return null; |
15998 } | 16062 } |
15999 if (identical(node, _oldNode)) { | 16063 if (identical(node, _oldNode)) { |
16000 return _newNode as ASTNode; | 16064 return _newNode; |
16001 } | 16065 } |
16002 return node.accept(this) as ASTNode; | 16066 return node.accept(this) as ASTNode; |
16003 } | 16067 } |
16004 | 16068 |
16005 List clone5(NodeList nodes) { | 16069 List clone5(NodeList nodes) { |
16006 List clonedNodes = new List(); | 16070 List clonedNodes = new List(); |
16007 for (ASTNode node in nodes) { | 16071 for (ASTNode node in nodes) { |
16008 clonedNodes.add(clone4(node)); | 16072 clonedNodes.add(clone4(node)); |
16009 } | 16073 } |
16010 return clonedNodes; | 16074 return clonedNodes; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16174 * Some statements define names that are visible downstream. There aren't many
of these. | 16238 * Some statements define names that are visible downstream. There aren't many
of these. |
16175 * | 16239 * |
16176 * @param statements the list of statements to check for name definitions | 16240 * @param statements the list of statements to check for name definitions |
16177 */ | 16241 */ |
16178 void checkStatements(List<Statement> statements) { | 16242 void checkStatements(List<Statement> statements) { |
16179 for (Statement stmt in statements) { | 16243 for (Statement stmt in statements) { |
16180 if (identical(stmt, _immediateChild)) { | 16244 if (identical(stmt, _immediateChild)) { |
16181 return; | 16245 return; |
16182 } | 16246 } |
16183 if (stmt is VariableDeclarationStatement) { | 16247 if (stmt is VariableDeclarationStatement) { |
16184 addVariables((stmt as VariableDeclarationStatement).variables.variables)
; | 16248 addVariables(stmt.variables.variables); |
16185 } else if (stmt is FunctionDeclarationStatement && !_referenceIsWithinLoca
lFunction) { | 16249 } else if (stmt is FunctionDeclarationStatement && !_referenceIsWithinLoca
lFunction) { |
16186 addToScope((stmt as FunctionDeclarationStatement).functionDeclaration.na
me); | 16250 addToScope(stmt.functionDeclaration.name); |
16187 } | 16251 } |
16188 } | 16252 } |
16189 } | 16253 } |
16190 | 16254 |
16191 bool isInRange(ASTNode node) { | 16255 bool isInRange(ASTNode node) { |
16192 if (_position < 0) { | 16256 if (_position < 0) { |
16193 return true; | 16257 return true; |
16194 } | 16258 } |
16195 return node.end < _position; | 16259 return node.end < _position; |
16196 } | 16260 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16307 } | 16371 } |
16308 void operator[]=(int index, E node) { | 16372 void operator[]=(int index, E node) { |
16309 if (index < 0 || index >= _elements.length) { | 16373 if (index < 0 || index >= _elements.length) { |
16310 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); | 16374 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); |
16311 } | 16375 } |
16312 owner.becomeParentOf(node); | 16376 owner.becomeParentOf(node); |
16313 _elements[index] = node; | 16377 _elements[index] = node; |
16314 } | 16378 } |
16315 int get length => _elements.length; | 16379 int get length => _elements.length; |
16316 } | 16380 } |
OLD | NEW |