| 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 library engine.resolver; | 3 library engine.resolver; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
| 8 import 'source.dart'; | 8 import 'source.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'scanner.dart' as sc; | 10 import 'scanner.dart' as sc; |
| (...skipping 3252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3263 } | 3263 } |
| 3264 } | 3264 } |
| 3265 } | 3265 } |
| 3266 } | 3266 } |
| 3267 return super.visitFieldFormalParameter(node); | 3267 return super.visitFieldFormalParameter(node); |
| 3268 } | 3268 } |
| 3269 Object visitFunctionDeclaration(FunctionDeclaration node) { | 3269 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 3270 setMetadata(node.element, node); | 3270 setMetadata(node.element, node); |
| 3271 return null; | 3271 return null; |
| 3272 } | 3272 } |
| 3273 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
null; | 3273 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 3274 Expression expression = node.function; |
| 3275 if (expression is FunctionExpression) { |
| 3276 FunctionExpression functionExpression = expression as FunctionExpression; |
| 3277 ExecutableElement functionElement = functionExpression.element; |
| 3278 ArgumentList argumentList = node.argumentList; |
| 3279 List<ParameterElement> parameters = resolveArgumentsToParameters(false, ar
gumentList, functionElement); |
| 3280 if (parameters != null) { |
| 3281 argumentList.correspondingStaticParameters = parameters; |
| 3282 } |
| 3283 } |
| 3284 return null; |
| 3285 } |
| 3274 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 3286 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 3275 setMetadata(node.element, node); | 3287 setMetadata(node.element, node); |
| 3276 return null; | 3288 return null; |
| 3277 } | 3289 } |
| 3278 Object visitImportDirective(ImportDirective node) { | 3290 Object visitImportDirective(ImportDirective node) { |
| 3279 SimpleIdentifier prefixNode = node.prefix; | 3291 SimpleIdentifier prefixNode = node.prefix; |
| 3280 if (prefixNode != null) { | 3292 if (prefixNode != null) { |
| 3281 String prefixName = prefixNode.name; | 3293 String prefixName = prefixNode.name; |
| 3282 for (PrefixElement prefixElement in _definingLibrary.prefixes) { | 3294 for (PrefixElement prefixElement in _definingLibrary.prefixes) { |
| 3283 if (prefixElement.displayName == prefixName) { | 3295 if (prefixElement.displayName == prefixName) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3484 SimpleIdentifier identifier = node.identifier; | 3496 SimpleIdentifier identifier = node.identifier; |
| 3485 Element prefixElement = prefix.staticElement; | 3497 Element prefixElement = prefix.staticElement; |
| 3486 if (prefixElement is PrefixElement) { | 3498 if (prefixElement is PrefixElement) { |
| 3487 Element element = _resolver.nameScope.lookup(node, _definingLibrary); | 3499 Element element = _resolver.nameScope.lookup(node, _definingLibrary); |
| 3488 if (element == null && identifier.inSetterContext()) { | 3500 if (element == null && identifier.inSetterContext()) { |
| 3489 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdenti
fier("${node.name}="), _definingLibrary); | 3501 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdenti
fier("${node.name}="), _definingLibrary); |
| 3490 } | 3502 } |
| 3491 if (element == null) { | 3503 if (element == null) { |
| 3492 if (identifier.inSetterContext()) { | 3504 if (identifier.inSetterContext()) { |
| 3493 _resolver.reportError5(StaticWarningCode.UNDEFINED_SETTER, identifier,
[identifier.name, prefixElement.name]); | 3505 _resolver.reportError5(StaticWarningCode.UNDEFINED_SETTER, identifier,
[identifier.name, prefixElement.name]); |
| 3506 } else if (node.parent is Annotation) { |
| 3507 Annotation annotation = node.parent as Annotation; |
| 3508 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annota
tion, []); |
| 3509 return null; |
| 3494 } else { | 3510 } else { |
| 3495 _resolver.reportError5(StaticWarningCode.UNDEFINED_GETTER, identifier,
[identifier.name, prefixElement.name]); | 3511 _resolver.reportError5(StaticWarningCode.UNDEFINED_GETTER, identifier,
[identifier.name, prefixElement.name]); |
| 3496 } | 3512 } |
| 3497 return null; | 3513 return null; |
| 3498 } | 3514 } |
| 3499 if (element is PropertyAccessorElement && identifier.inSetterContext()) { | 3515 if (element is PropertyAccessorElement && identifier.inSetterContext()) { |
| 3500 PropertyInducingElement variable = ((element as PropertyAccessorElement)
).variable; | 3516 PropertyInducingElement variable = ((element as PropertyAccessorElement)
).variable; |
| 3501 if (variable != null) { | 3517 if (variable != null) { |
| 3502 PropertyAccessorElement setter = variable.setter; | 3518 PropertyAccessorElement setter = variable.setter; |
| 3503 if (setter != null) { | 3519 if (setter != null) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3595 Element element = resolveSimpleIdentifier(node); | 3611 Element element = resolveSimpleIdentifier(node); |
| 3596 ClassElement enclosingClass = _resolver.enclosingClass; | 3612 ClassElement enclosingClass = _resolver.enclosingClass; |
| 3597 if (isFactoryConstructorReturnType(node) && element != enclosingClass) { | 3613 if (isFactoryConstructorReturnType(node) && element != enclosingClass) { |
| 3598 _resolver.reportError5(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLA
SS, node, []); | 3614 _resolver.reportError5(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLA
SS, node, []); |
| 3599 } else if (isConstructorReturnType(node) && element != enclosingClass) { | 3615 } else if (isConstructorReturnType(node) && element != enclosingClass) { |
| 3600 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node
, []); | 3616 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node
, []); |
| 3601 element = null; | 3617 element = null; |
| 3602 } else if (element == null || (element is PrefixElement && !isValidAsPrefix(
node))) { | 3618 } else if (element == null || (element is PrefixElement && !isValidAsPrefix(
node))) { |
| 3603 if (isConstructorReturnType(node)) { | 3619 if (isConstructorReturnType(node)) { |
| 3604 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, no
de, []); | 3620 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, no
de, []); |
| 3621 } else if (node.parent is Annotation) { |
| 3622 Annotation annotation = node.parent as Annotation; |
| 3623 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
| 3605 } else { | 3624 } else { |
| 3606 _resolver.reportErrorProxyConditionalAnalysisError(_resolver.enclosingCl
ass, StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]); | 3625 _resolver.reportErrorProxyConditionalAnalysisError(_resolver.enclosingCl
ass, StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]); |
| 3607 } | 3626 } |
| 3608 } | 3627 } |
| 3609 node.staticElement = element; | 3628 node.staticElement = element; |
| 3610 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { | 3629 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { |
| 3611 InterfaceType enclosingType = enclosingClass.type; | 3630 InterfaceType enclosingType = enclosingClass.type; |
| 3612 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(lookUpGetter(n
ull, enclosingType, node.name), null); | 3631 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(lookUpGetter(n
ull, enclosingType, node.name), null); |
| 3613 node.auxiliaryElements = auxiliaryElements; | 3632 node.auxiliaryElements = auxiliaryElements; |
| 3614 } | 3633 } |
| (...skipping 3682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7297 * the given expression with the given type. Generally speaking, it is appropr
iate if the given | 7316 * the given expression with the given type. Generally speaking, it is appropr
iate if the given |
| 7298 * type is more specific than the current type. | 7317 * type is more specific than the current type. |
| 7299 * | 7318 * |
| 7300 * @param expression the expression used to access the static element whose ty
pes might be | 7319 * @param expression the expression used to access the static element whose ty
pes might be |
| 7301 * promoted | 7320 * promoted |
| 7302 * @param potentialType the potential type of the elements | 7321 * @param potentialType the potential type of the elements |
| 7303 */ | 7322 */ |
| 7304 void promote(Expression expression, Type2 potentialType) { | 7323 void promote(Expression expression, Type2 potentialType) { |
| 7305 VariableElement element = getPromotionStaticElement(expression); | 7324 VariableElement element = getPromotionStaticElement(expression); |
| 7306 if (element != null) { | 7325 if (element != null) { |
| 7326 if (((element as VariableElementImpl)).isPotentiallyMutatedInClosure) { |
| 7327 return; |
| 7328 } |
| 7307 Type2 type = expression.staticType; | 7329 Type2 type = expression.staticType; |
| 7308 if (type == null || type.isDynamic) { | 7330 if (type == null || type.isDynamic) { |
| 7309 return; | 7331 return; |
| 7310 } | 7332 } |
| 7311 if (potentialType == null || potentialType.isDynamic) { | 7333 if (potentialType == null || potentialType.isDynamic) { |
| 7312 return; | 7334 return; |
| 7313 } | 7335 } |
| 7314 if (!potentialType.isMoreSpecificThan(type)) { | 7336 if (!potentialType.isMoreSpecificThan(type)) { |
| 7315 return; | 7337 return; |
| 7316 } | 7338 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7404 | 7426 |
| 7405 /** | 7427 /** |
| 7406 * Checks each promoted variable in the current scope for compliance with the
following | 7428 * Checks each promoted variable in the current scope for compliance with the
following |
| 7407 * specification statement: | 7429 * specification statement: |
| 7408 * | 7430 * |
| 7409 * If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> t
hen the variable | 7431 * If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> t
hen the variable |
| 7410 * <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>. | 7432 * <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>. |
| 7411 */ | 7433 */ |
| 7412 void clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(ASTNode target
) { | 7434 void clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(ASTNode target
) { |
| 7413 for (Element element in promoteManager.promotedElements) { | 7435 for (Element element in promoteManager.promotedElements) { |
| 7414 if (((element as VariableElementImpl)).isPotentiallyMutated) { | 7436 if (((element as VariableElementImpl)).isPotentiallyMutatedInScope) { |
| 7415 if (isVariableAccessedInClosure(element, target)) { | 7437 if (isVariableAccessedInClosure(element, target)) { |
| 7416 promoteManager.setType(element, null); | 7438 promoteManager.setType(element, null); |
| 7417 } | 7439 } |
| 7418 } | 7440 } |
| 7419 } | 7441 } |
| 7420 } | 7442 } |
| 7421 | 7443 |
| 7422 /** | 7444 /** |
| 7423 * Checks each promoted variable in the current scope for compliance with the
following | 7445 * Checks each promoted variable in the current scope for compliance with the
following |
| 7424 * specification statement: | 7446 * specification statement: |
| (...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9062 SimpleIdentifier prefixedIdentifier = node.identifier; | 9084 SimpleIdentifier prefixedIdentifier = node.identifier; |
| 9063 Element staticElement = prefixedIdentifier.staticElement; | 9085 Element staticElement = prefixedIdentifier.staticElement; |
| 9064 Type2 staticType = _dynamicType; | 9086 Type2 staticType = _dynamicType; |
| 9065 if (staticElement is ClassElement) { | 9087 if (staticElement is ClassElement) { |
| 9066 if (isNotTypeLiteral(node)) { | 9088 if (isNotTypeLiteral(node)) { |
| 9067 staticType = ((staticElement as ClassElement)).type; | 9089 staticType = ((staticElement as ClassElement)).type; |
| 9068 } else { | 9090 } else { |
| 9069 staticType = _typeProvider.typeType; | 9091 staticType = _typeProvider.typeType; |
| 9070 } | 9092 } |
| 9071 } else if (staticElement is FunctionTypeAliasElement) { | 9093 } else if (staticElement is FunctionTypeAliasElement) { |
| 9072 staticType = ((staticElement as FunctionTypeAliasElement)).type; | 9094 if (isNotTypeLiteral(node)) { |
| 9095 staticType = ((staticElement as FunctionTypeAliasElement)).type; |
| 9096 } else { |
| 9097 staticType = _typeProvider.typeType; |
| 9098 } |
| 9073 } else if (staticElement is MethodElement) { | 9099 } else if (staticElement is MethodElement) { |
| 9074 staticType = ((staticElement as MethodElement)).type; | 9100 staticType = ((staticElement as MethodElement)).type; |
| 9075 } else if (staticElement is PropertyAccessorElement) { | 9101 } else if (staticElement is PropertyAccessorElement) { |
| 9076 staticType = getType(staticElement as PropertyAccessorElement, node.prefix
.staticType); | 9102 staticType = getType(staticElement as PropertyAccessorElement, node.prefix
.staticType); |
| 9077 } else if (staticElement is ExecutableElement) { | 9103 } else if (staticElement is ExecutableElement) { |
| 9078 staticType = ((staticElement as ExecutableElement)).type; | 9104 staticType = ((staticElement as ExecutableElement)).type; |
| 9079 } else if (staticElement is TypeParameterElement) { | 9105 } else if (staticElement is TypeParameterElement) { |
| 9080 staticType = ((staticElement as TypeParameterElement)).type; | 9106 staticType = ((staticElement as TypeParameterElement)).type; |
| 9081 } else if (staticElement is VariableElement) { | 9107 } else if (staticElement is VariableElement) { |
| 9082 staticType = ((staticElement as VariableElement)).type; | 9108 staticType = ((staticElement as VariableElement)).type; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9261 Object visitSimpleIdentifier(SimpleIdentifier node) { | 9287 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 9262 Element element = node.staticElement; | 9288 Element element = node.staticElement; |
| 9263 Type2 staticType = _dynamicType; | 9289 Type2 staticType = _dynamicType; |
| 9264 if (element is ClassElement) { | 9290 if (element is ClassElement) { |
| 9265 if (isNotTypeLiteral(node)) { | 9291 if (isNotTypeLiteral(node)) { |
| 9266 staticType = ((element as ClassElement)).type; | 9292 staticType = ((element as ClassElement)).type; |
| 9267 } else { | 9293 } else { |
| 9268 staticType = _typeProvider.typeType; | 9294 staticType = _typeProvider.typeType; |
| 9269 } | 9295 } |
| 9270 } else if (element is FunctionTypeAliasElement) { | 9296 } else if (element is FunctionTypeAliasElement) { |
| 9271 staticType = ((element as FunctionTypeAliasElement)).type; | 9297 if (isNotTypeLiteral(node)) { |
| 9298 staticType = ((element as FunctionTypeAliasElement)).type; |
| 9299 } else { |
| 9300 staticType = _typeProvider.typeType; |
| 9301 } |
| 9272 } else if (element is MethodElement) { | 9302 } else if (element is MethodElement) { |
| 9273 staticType = ((element as MethodElement)).type; | 9303 staticType = ((element as MethodElement)).type; |
| 9274 } else if (element is PropertyAccessorElement) { | 9304 } else if (element is PropertyAccessorElement) { |
| 9275 staticType = getType(element as PropertyAccessorElement, null); | 9305 staticType = getType(element as PropertyAccessorElement, null); |
| 9276 } else if (element is ExecutableElement) { | 9306 } else if (element is ExecutableElement) { |
| 9277 staticType = ((element as ExecutableElement)).type; | 9307 staticType = ((element as ExecutableElement)).type; |
| 9278 } else if (element is TypeParameterElement) { | 9308 } else if (element is TypeParameterElement) { |
| 9279 staticType = ((element as TypeParameterElement)).type; | 9309 staticType = ((element as TypeParameterElement)).type; |
| 9280 } else if (element is VariableElement) { | 9310 } else if (element is VariableElement) { |
| 9281 VariableElement variable = element as VariableElement; | 9311 VariableElement variable = element as VariableElement; |
| (...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11394 } | 11424 } |
| 11395 /** | 11425 /** |
| 11396 * Instances of the class `VariableResolverVisitor` are used to resolve | 11426 * Instances of the class `VariableResolverVisitor` are used to resolve |
| 11397 * [SimpleIdentifier]s to local variables and formal parameters. | 11427 * [SimpleIdentifier]s to local variables and formal parameters. |
| 11398 * | 11428 * |
| 11399 * @coverage dart.engine.resolver | 11429 * @coverage dart.engine.resolver |
| 11400 */ | 11430 */ |
| 11401 class VariableResolverVisitor extends ScopedVisitor { | 11431 class VariableResolverVisitor extends ScopedVisitor { |
| 11402 | 11432 |
| 11403 /** | 11433 /** |
| 11434 * The method or function that we are currently visiting, or `null` if we are
not inside a |
| 11435 * method or function. |
| 11436 */ |
| 11437 ExecutableElement _enclosingFunction; |
| 11438 |
| 11439 /** |
| 11404 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 11440 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
| 11405 * | 11441 * |
| 11406 * @param library the library containing the compilation unit being resolved | 11442 * @param library the library containing the compilation unit being resolved |
| 11407 * @param source the source representing the compilation unit being visited | 11443 * @param source the source representing the compilation unit being visited |
| 11408 * @param typeProvider the object used to access the types from the core libra
ry | 11444 * @param typeProvider the object used to access the types from the core libra
ry |
| 11409 */ | 11445 */ |
| 11410 VariableResolverVisitor(Library library, Source source, TypeProvider typeProvi
der) : super.con1(library, source, typeProvider); | 11446 VariableResolverVisitor(Library library, Source source, TypeProvider typeProvi
der) : super.con1(library, source, typeProvider); |
| 11447 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 11448 ExecutableElement outerFunction = _enclosingFunction; |
| 11449 try { |
| 11450 _enclosingFunction = node.element; |
| 11451 return super.visitFunctionDeclaration(node); |
| 11452 } finally { |
| 11453 _enclosingFunction = outerFunction; |
| 11454 } |
| 11455 } |
| 11456 Object visitFunctionExpression(FunctionExpression node) { |
| 11457 if (node.parent is! FunctionDeclaration) { |
| 11458 ExecutableElement outerFunction = _enclosingFunction; |
| 11459 try { |
| 11460 _enclosingFunction = node.element; |
| 11461 return super.visitFunctionExpression(node); |
| 11462 } finally { |
| 11463 _enclosingFunction = outerFunction; |
| 11464 } |
| 11465 } else { |
| 11466 return super.visitFunctionExpression(node); |
| 11467 } |
| 11468 } |
| 11411 Object visitSimpleIdentifier(SimpleIdentifier node) { | 11469 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 11412 if (node.staticElement != null) { | 11470 if (node.staticElement != null) { |
| 11413 return null; | 11471 return null; |
| 11414 } | 11472 } |
| 11415 ASTNode parent = node.parent; | 11473 ASTNode parent = node.parent; |
| 11416 if (parent is PrefixedIdentifier && identical(((parent as PrefixedIdentifier
)).identifier, node)) { | 11474 if (parent is PrefixedIdentifier && identical(((parent as PrefixedIdentifier
)).identifier, node)) { |
| 11417 return null; | 11475 return null; |
| 11418 } | 11476 } |
| 11419 if (parent is PropertyAccess && identical(((parent as PropertyAccess)).prope
rtyName, node)) { | 11477 if (parent is PropertyAccess && identical(((parent as PropertyAccess)).prope
rtyName, node)) { |
| 11420 return null; | 11478 return null; |
| 11421 } | 11479 } |
| 11422 if (parent is MethodInvocation && identical(((parent as MethodInvocation)).m
ethodName, node)) { | 11480 if (parent is MethodInvocation && identical(((parent as MethodInvocation)).m
ethodName, node)) { |
| 11423 return null; | 11481 return null; |
| 11424 } | 11482 } |
| 11425 if (parent is ConstructorName) { | 11483 if (parent is ConstructorName) { |
| 11426 return null; | 11484 return null; |
| 11427 } | 11485 } |
| 11428 if (parent is Label) { | 11486 if (parent is Label) { |
| 11429 return null; | 11487 return null; |
| 11430 } | 11488 } |
| 11431 Element element = nameScope.lookup(node, definingLibrary); | 11489 Element element = nameScope.lookup(node, definingLibrary); |
| 11432 if (element is! VariableElement) { | 11490 if (element is! VariableElement) { |
| 11433 return null; | 11491 return null; |
| 11434 } | 11492 } |
| 11435 ElementKind kind = element.kind; | 11493 ElementKind kind = element.kind; |
| 11436 if (identical(kind, ElementKind.LOCAL_VARIABLE)) { | 11494 if (identical(kind, ElementKind.LOCAL_VARIABLE)) { |
| 11437 node.staticElement = element; | 11495 node.staticElement = element; |
| 11438 if (node.inSetterContext()) { | 11496 if (node.inSetterContext()) { |
| 11439 ((element as LocalVariableElementImpl)).markPotentiallyMutated(); | 11497 LocalVariableElementImpl variableImpl = element as LocalVariableElementI
mpl; |
| 11498 variableImpl.markPotentiallyMutatedInScope(); |
| 11499 if (element.enclosingElement != _enclosingFunction) { |
| 11500 variableImpl.markPotentiallyMutatedInClosure(); |
| 11501 } |
| 11440 } | 11502 } |
| 11441 } else if (identical(kind, ElementKind.PARAMETER)) { | 11503 } else if (identical(kind, ElementKind.PARAMETER)) { |
| 11442 node.staticElement = element; | 11504 node.staticElement = element; |
| 11443 if (node.inSetterContext()) { | 11505 if (node.inSetterContext()) { |
| 11444 ((element as ParameterElementImpl)).markPotentiallyMutated(); | 11506 ParameterElementImpl parameterImpl = element as ParameterElementImpl; |
| 11507 parameterImpl.markPotentiallyMutatedInScope(); |
| 11508 if (_enclosingFunction != null && (element.enclosingElement != _enclosin
gFunction)) { |
| 11509 parameterImpl.markPotentiallyMutatedInClosure(); |
| 11510 } |
| 11445 } | 11511 } |
| 11446 } | 11512 } |
| 11447 return null; | 11513 return null; |
| 11448 } | 11514 } |
| 11449 } | 11515 } |
| 11450 /** | 11516 /** |
| 11451 * Instances of the class `ClassScope` implement the scope defined by a class. | 11517 * Instances of the class `ClassScope` implement the scope defined by a class. |
| 11452 * | 11518 * |
| 11453 * @coverage dart.engine.resolver | 11519 * @coverage dart.engine.resolver |
| 11454 */ | 11520 */ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11522 Set<String> _hiddenNames = new Set<String>(); | 11588 Set<String> _hiddenNames = new Set<String>(); |
| 11523 | 11589 |
| 11524 /** | 11590 /** |
| 11525 * Initialize a newly created scope enclosed within another scope. | 11591 * Initialize a newly created scope enclosed within another scope. |
| 11526 * | 11592 * |
| 11527 * @param enclosingScope the scope in which this scope is lexically enclosed | 11593 * @param enclosingScope the scope in which this scope is lexically enclosed |
| 11528 */ | 11594 */ |
| 11529 EnclosedScope(Scope enclosingScope) { | 11595 EnclosedScope(Scope enclosingScope) { |
| 11530 this.enclosingScope = enclosingScope; | 11596 this.enclosingScope = enclosingScope; |
| 11531 } | 11597 } |
| 11532 LibraryElement get definingLibrary => enclosingScope.definingLibrary; | |
| 11533 AnalysisErrorListener get errorListener => enclosingScope.errorListener; | 11598 AnalysisErrorListener get errorListener => enclosingScope.errorListener; |
| 11534 | 11599 |
| 11535 /** | 11600 /** |
| 11536 * Hides the name of the given element in this scope. If there is already an e
lement with the | 11601 * Hides the name of the given element in this scope. If there is already an e
lement with the |
| 11537 * given name defined in an outer scope, then it will become unavailable. | 11602 * given name defined in an outer scope, then it will become unavailable. |
| 11538 * | 11603 * |
| 11539 * @param element the element to be hidden in this scope | 11604 * @param element the element to be hidden in this scope |
| 11540 */ | 11605 */ |
| 11541 void hide(Element element) { | 11606 void hide(Element element) { |
| 11542 if (element != null) { | 11607 if (element != null) { |
| 11543 String name = element.name; | 11608 String name = element.name; |
| 11544 if (name != null && !name.isEmpty) { | 11609 if (name != null && !name.isEmpty) { |
| 11545 javaSetAdd(_hiddenNames, name); | 11610 javaSetAdd(_hiddenNames, name); |
| 11546 } | 11611 } |
| 11547 } | 11612 } |
| 11548 } | 11613 } |
| 11549 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) { | 11614 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) { |
| 11550 Element element = localLookup(name, referencingLibrary); | 11615 Element element = localLookup(name, referencingLibrary); |
| 11551 if (element != null) { | 11616 if (element != null) { |
| 11552 return element; | 11617 return element; |
| 11553 } | 11618 } |
| 11554 if (_hiddenNames.contains(name)) { | 11619 if (_hiddenNames.contains(name)) { |
| 11555 errorListener.onError(new AnalysisError.con2(source, identifier.offset, id
entifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, [])); | 11620 errorListener.onError(new AnalysisError.con2(getSource(identifier), identi
fier.offset, identifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATI
ON, [])); |
| 11556 } | 11621 } |
| 11557 return enclosingScope.lookup3(identifier, name, referencingLibrary); | 11622 return enclosingScope.lookup3(identifier, name, referencingLibrary); |
| 11558 } | 11623 } |
| 11559 } | 11624 } |
| 11560 /** | 11625 /** |
| 11561 * Instances of the class `FunctionScope` implement the scope defined by a funct
ion. | 11626 * Instances of the class `FunctionScope` implement the scope defined by a funct
ion. |
| 11562 * | 11627 * |
| 11563 * @coverage dart.engine.resolver | 11628 * @coverage dart.engine.resolver |
| 11564 */ | 11629 */ |
| 11565 class FunctionScope extends EnclosedScope { | 11630 class FunctionScope extends EnclosedScope { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11763 LibraryImportScope(LibraryElement definingLibrary, AnalysisErrorListener error
Listener) { | 11828 LibraryImportScope(LibraryElement definingLibrary, AnalysisErrorListener error
Listener) { |
| 11764 this._definingLibrary = definingLibrary; | 11829 this._definingLibrary = definingLibrary; |
| 11765 this._errorListener = errorListener; | 11830 this._errorListener = errorListener; |
| 11766 createImportedNamespaces(definingLibrary); | 11831 createImportedNamespaces(definingLibrary); |
| 11767 } | 11832 } |
| 11768 void define(Element element) { | 11833 void define(Element element) { |
| 11769 if (!Scope.isPrivateName(element.displayName)) { | 11834 if (!Scope.isPrivateName(element.displayName)) { |
| 11770 super.define(element); | 11835 super.define(element); |
| 11771 } | 11836 } |
| 11772 } | 11837 } |
| 11773 LibraryElement get definingLibrary => _definingLibrary; | |
| 11774 AnalysisErrorListener get errorListener => _errorListener; | 11838 AnalysisErrorListener get errorListener => _errorListener; |
| 11775 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) { | 11839 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) { |
| 11776 Element foundElement = localLookup(name, referencingLibrary); | 11840 Element foundElement = localLookup(name, referencingLibrary); |
| 11777 if (foundElement != null) { | 11841 if (foundElement != null) { |
| 11778 return foundElement; | 11842 return foundElement; |
| 11779 } | 11843 } |
| 11780 for (Namespace nameSpace in _importedNamespaces) { | 11844 for (Namespace nameSpace in _importedNamespaces) { |
| 11781 Element element = nameSpace.get(name); | 11845 Element element = nameSpace.get(name); |
| 11782 if (element != null) { | 11846 if (element != null) { |
| 11783 if (foundElement == null) { | 11847 if (foundElement == null) { |
| 11784 foundElement = element; | 11848 foundElement = element; |
| 11785 } else if (foundElement != element) { | 11849 } else if (foundElement != element) { |
| 11786 foundElement = MultiplyDefinedElementImpl.fromElements(_definingLibrar
y.context, foundElement, element); | 11850 foundElement = MultiplyDefinedElementImpl.fromElements(_definingLibrar
y.context, foundElement, element); |
| 11787 } | 11851 } |
| 11788 } | 11852 } |
| 11789 } | 11853 } |
| 11790 if (foundElement is MultiplyDefinedElementImpl) { | 11854 if (foundElement is MultiplyDefinedElementImpl) { |
| 11791 foundElement = removeSdkElements(identifier, name, foundElement as Multipl
yDefinedElementImpl); | 11855 foundElement = removeSdkElements(identifier, name, foundElement as Multipl
yDefinedElementImpl); |
| 11792 } | 11856 } |
| 11793 if (foundElement is MultiplyDefinedElementImpl) { | 11857 if (foundElement is MultiplyDefinedElementImpl) { |
| 11794 String foundEltName = foundElement.displayName; | 11858 String foundEltName = foundElement.displayName; |
| 11795 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; | 11859 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; |
| 11796 String libName1 = getLibraryName(conflictingMembers[0], ""); | 11860 String libName1 = getLibraryName(conflictingMembers[0], ""); |
| 11797 String libName2 = getLibraryName(conflictingMembers[1], ""); | 11861 String libName2 = getLibraryName(conflictingMembers[1], ""); |
| 11798 _errorListener.onError(new AnalysisError.con2(getSource2(identifier), iden
tifier.offset, identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltN
ame, libName1, libName2])); | 11862 _errorListener.onError(new AnalysisError.con2(getSource(identifier), ident
ifier.offset, identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltNa
me, libName1, libName2])); |
| 11799 return foundElement; | 11863 return foundElement; |
| 11800 } | 11864 } |
| 11801 if (foundElement != null) { | 11865 if (foundElement != null) { |
| 11802 defineWithoutChecking2(name, foundElement); | 11866 defineWithoutChecking2(name, foundElement); |
| 11803 } | 11867 } |
| 11804 return foundElement; | 11868 return foundElement; |
| 11805 } | 11869 } |
| 11806 | 11870 |
| 11807 /** | 11871 /** |
| 11808 * Create all of the namespaces associated with the libraries imported into th
is library. The | 11872 * Create all of the namespaces associated with the libraries imported into th
is library. The |
| (...skipping 21 matching lines...) Expand all Loading... |
| 11830 return def; | 11894 return def; |
| 11831 } | 11895 } |
| 11832 LibraryElement library = element.library; | 11896 LibraryElement library = element.library; |
| 11833 if (library == null) { | 11897 if (library == null) { |
| 11834 return def; | 11898 return def; |
| 11835 } | 11899 } |
| 11836 return library.definingCompilationUnit.displayName; | 11900 return library.definingCompilationUnit.displayName; |
| 11837 } | 11901 } |
| 11838 | 11902 |
| 11839 /** | 11903 /** |
| 11840 * Return the source that contains the given identifier, or the source associa
ted with this scope | |
| 11841 * if the source containing the identifier could not be determined. | |
| 11842 * | |
| 11843 * @param identifier the identifier whose source is to be returned | |
| 11844 * @return the source that contains the given identifier | |
| 11845 */ | |
| 11846 Source getSource2(Identifier identifier) { | |
| 11847 CompilationUnit unit = identifier.getAncestor(CompilationUnit); | |
| 11848 if (unit != null) { | |
| 11849 CompilationUnitElement element = unit.element; | |
| 11850 if (element != null) { | |
| 11851 Source source = element.source; | |
| 11852 if (source != null) { | |
| 11853 return source; | |
| 11854 } | |
| 11855 } | |
| 11856 } | |
| 11857 return this.source; | |
| 11858 } | |
| 11859 | |
| 11860 /** | |
| 11861 * Given a collection of elements that a single name could all be mapped to, r
emove from the list | 11904 * Given a collection of elements that a single name could all be mapped to, r
emove from the list |
| 11862 * all of the names defined in the SDK. Return the element(s) that remain. | 11905 * all of the names defined in the SDK. Return the element(s) that remain. |
| 11863 * | 11906 * |
| 11864 * @param identifier the identifier node to lookup element for, used to report
correct kind of a | 11907 * @param identifier the identifier node to lookup element for, used to report
correct kind of a |
| 11865 * problem and associate problem with | 11908 * problem and associate problem with |
| 11866 * @param name the name associated with the element | 11909 * @param name the name associated with the element |
| 11867 * @param foundElement the element encapsulating the collection of elements | 11910 * @param foundElement the element encapsulating the collection of elements |
| 11868 * @return all of the elements that are not defined in the SDK | 11911 * @return all of the elements that are not defined in the SDK |
| 11869 */ | 11912 */ |
| 11870 Element removeSdkElements(Identifier identifier, String name, MultiplyDefinedE
lementImpl foundElement) { | 11913 Element removeSdkElements(Identifier identifier, String name, MultiplyDefinedE
lementImpl foundElement) { |
| 11871 List<Element> conflictingMembers = foundElement.conflictingElements; | 11914 List<Element> conflictingMembers = foundElement.conflictingElements; |
| 11872 int length = conflictingMembers.length; | 11915 int length = conflictingMembers.length; |
| 11873 int to = 0; | 11916 int to = 0; |
| 11874 Element sdkElement = null; | 11917 Element sdkElement = null; |
| 11875 for (Element member in conflictingMembers) { | 11918 for (Element member in conflictingMembers) { |
| 11876 if (member.library.isInSdk) { | 11919 if (member.library.isInSdk) { |
| 11877 sdkElement = member; | 11920 sdkElement = member; |
| 11878 } else { | 11921 } else { |
| 11879 conflictingMembers[to++] = member; | 11922 conflictingMembers[to++] = member; |
| 11880 } | 11923 } |
| 11881 } | 11924 } |
| 11882 if (sdkElement != null && to > 0) { | 11925 if (sdkElement != null && to > 0) { |
| 11883 String sdkLibName = getLibraryName(sdkElement, ""); | 11926 String sdkLibName = getLibraryName(sdkElement, ""); |
| 11884 String otherLibName = getLibraryName(conflictingMembers[0], ""); | 11927 String otherLibName = getLibraryName(conflictingMembers[0], ""); |
| 11885 _errorListener.onError(new AnalysisError.con2(getSource2(identifier), iden
tifier.offset, identifier.length, StaticWarningCode.CONFLICTING_DART_IMPORT, [na
me, sdkLibName, otherLibName])); | 11928 _errorListener.onError(new AnalysisError.con2(getSource(identifier), ident
ifier.offset, identifier.length, StaticWarningCode.CONFLICTING_DART_IMPORT, [nam
e, sdkLibName, otherLibName])); |
| 11886 } | 11929 } |
| 11887 if (to == length) { | 11930 if (to == length) { |
| 11888 return foundElement; | 11931 return foundElement; |
| 11889 } else if (to == 1) { | 11932 } else if (to == 1) { |
| 11890 return conflictingMembers[0]; | 11933 return conflictingMembers[0]; |
| 11891 } else if (to == 0) { | 11934 } else if (to == 0) { |
| 11892 AnalysisEngine.instance.logger.logInformation("Multiply defined SDK elemen
t: ${foundElement}"); | 11935 AnalysisEngine.instance.logger.logInformation("Multiply defined SDK elemen
t: ${foundElement}"); |
| 11893 return foundElement; | 11936 return foundElement; |
| 11894 } | 11937 } |
| 11895 List<Element> remaining = new List<Element>(to); | 11938 List<Element> remaining = new List<Element>(to); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 11916 } | 11959 } |
| 11917 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 11960 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 11918 if (existing is PrefixElement) { | 11961 if (existing is PrefixElement) { |
| 11919 int offset = duplicate.nameOffset; | 11962 int offset = duplicate.nameOffset; |
| 11920 if (duplicate is PropertyAccessorElement) { | 11963 if (duplicate is PropertyAccessorElement) { |
| 11921 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement; | 11964 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement; |
| 11922 if (accessor.isSynthetic) { | 11965 if (accessor.isSynthetic) { |
| 11923 offset = accessor.variable.nameOffset; | 11966 offset = accessor.variable.nameOffset; |
| 11924 } | 11967 } |
| 11925 } | 11968 } |
| 11926 return new AnalysisError.con2(source, offset, duplicate.displayName.length
, CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existing.displayN
ame]); | 11969 return new AnalysisError.con2(duplicate.source, offset, duplicate.displayN
ame.length, CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existin
g.displayName]); |
| 11927 } | 11970 } |
| 11928 return super.getErrorForDuplicate(existing, duplicate); | 11971 return super.getErrorForDuplicate(existing, duplicate); |
| 11929 } | 11972 } |
| 11930 | 11973 |
| 11931 /** | 11974 /** |
| 11932 * Add to this scope all of the public top-level names that are defined in the
given compilation | 11975 * Add to this scope all of the public top-level names that are defined in the
given compilation |
| 11933 * unit. | 11976 * unit. |
| 11934 * | 11977 * |
| 11935 * @param compilationUnit the compilation unit defining the top-level names to
be added to this | 11978 * @param compilationUnit the compilation unit defining the top-level names to
be added to this |
| 11936 * scope | 11979 * scope |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12319 * Add the given element to this scope without checking for duplication or hid
ing. | 12362 * Add the given element to this scope without checking for duplication or hid
ing. |
| 12320 * | 12363 * |
| 12321 * @param name the name of the element to be added | 12364 * @param name the name of the element to be added |
| 12322 * @param element the element to be added to this scope | 12365 * @param element the element to be added to this scope |
| 12323 */ | 12366 */ |
| 12324 void defineWithoutChecking2(String name, Element element) { | 12367 void defineWithoutChecking2(String name, Element element) { |
| 12325 _definedNames[name] = element; | 12368 _definedNames[name] = element; |
| 12326 } | 12369 } |
| 12327 | 12370 |
| 12328 /** | 12371 /** |
| 12329 * Return the element representing the library in which this scope is enclosed
. | |
| 12330 * | |
| 12331 * @return the element representing the library in which this scope is enclose
d | |
| 12332 */ | |
| 12333 LibraryElement get definingLibrary; | |
| 12334 | |
| 12335 /** | |
| 12336 * Return the error code to be used when reporting that a name being defined l
ocally conflicts | 12372 * Return the error code to be used when reporting that a name being defined l
ocally conflicts |
| 12337 * with another element of the same name in the local scope. | 12373 * with another element of the same name in the local scope. |
| 12338 * | 12374 * |
| 12339 * @param existing the first element to be declared with the conflicting name | 12375 * @param existing the first element to be declared with the conflicting name |
| 12340 * @param duplicate another element declared with the conflicting name | 12376 * @param duplicate another element declared with the conflicting name |
| 12341 * @return the error code used to report duplicate names within a scope | 12377 * @return the error code used to report duplicate names within a scope |
| 12342 */ | 12378 */ |
| 12343 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 12379 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 12344 Source source = duplicate.source; | 12380 Source source = duplicate.source; |
| 12345 if (source == null) { | |
| 12346 source = this.source; | |
| 12347 } | |
| 12348 return new AnalysisError.con2(source, duplicate.nameOffset, duplicate.displa
yName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName])
; | 12381 return new AnalysisError.con2(source, duplicate.nameOffset, duplicate.displa
yName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName])
; |
| 12349 } | 12382 } |
| 12350 | 12383 |
| 12351 /** | 12384 /** |
| 12352 * Return the listener that is to be informed when an error is encountered. | 12385 * Return the listener that is to be informed when an error is encountered. |
| 12353 * | 12386 * |
| 12354 * @return the listener that is to be informed when an error is encountered | 12387 * @return the listener that is to be informed when an error is encountered |
| 12355 */ | 12388 */ |
| 12356 AnalysisErrorListener get errorListener; | 12389 AnalysisErrorListener get errorListener; |
| 12357 | 12390 |
| 12358 /** | 12391 /** |
| 12359 * Return the source object representing the compilation unit with which error
s related to this | 12392 * Return the source that contains the given identifier, or the source associa
ted with this scope |
| 12360 * scope should be associated. | 12393 * if the source containing the identifier could not be determined. |
| 12361 * | 12394 * |
| 12362 * @return the source object with which errors should be associated | 12395 * @param identifier the identifier whose source is to be returned |
| 12396 * @return the source that contains the given identifier |
| 12363 */ | 12397 */ |
| 12364 Source get source => definingLibrary.definingCompilationUnit.source; | 12398 Source getSource(ASTNode node) { |
| 12399 CompilationUnit unit = node.getAncestor(CompilationUnit); |
| 12400 if (unit != null) { |
| 12401 CompilationUnitElement unitElement = unit.element; |
| 12402 if (unitElement != null) { |
| 12403 return unitElement.source; |
| 12404 } |
| 12405 } |
| 12406 return null; |
| 12407 } |
| 12365 | 12408 |
| 12366 /** | 12409 /** |
| 12367 * Return the element with which the given name is associated, or `null` if th
e name is not | 12410 * Return the element with which the given name is associated, or `null` if th
e name is not |
| 12368 * defined within this scope. This method only returns elements that are direc
tly defined within | 12411 * defined within this scope. This method only returns elements that are direc
tly defined within |
| 12369 * this scope, not elements that are defined in an enclosing scope. | 12412 * this scope, not elements that are defined in an enclosing scope. |
| 12370 * | 12413 * |
| 12371 * @param name the name associated with the element to be returned | 12414 * @param name the name associated with the element to be returned |
| 12372 * @param referencingLibrary the library that contains the reference to the na
me, used to | 12415 * @param referencingLibrary the library that contains the reference to the na
me, used to |
| 12373 * implement library-level privacy | 12416 * implement library-level privacy |
| 12374 * @return the element with which the given name is associated | 12417 * @return the element with which the given name is associated |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13379 } | 13422 } |
| 13380 checkForAllReturnStatementErrorCodes(node); | 13423 checkForAllReturnStatementErrorCodes(node); |
| 13381 return super.visitReturnStatement(node); | 13424 return super.visitReturnStatement(node); |
| 13382 } | 13425 } |
| 13383 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 13426 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 13384 checkForConstFormalParameter(node); | 13427 checkForConstFormalParameter(node); |
| 13385 checkForPrivateOptionalParameter(node); | 13428 checkForPrivateOptionalParameter(node); |
| 13386 return super.visitSimpleFormalParameter(node); | 13429 return super.visitSimpleFormalParameter(node); |
| 13387 } | 13430 } |
| 13388 Object visitSimpleIdentifier(SimpleIdentifier node) { | 13431 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 13389 checkForReferenceToDeclaredVariableInInitializer(node); | |
| 13390 checkForImplicitThisReferenceInInitializer(node); | 13432 checkForImplicitThisReferenceInInitializer(node); |
| 13391 if (!isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) { | 13433 if (!isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) { |
| 13392 checkForUnqualifiedReferenceToNonLocalStaticMember(node); | 13434 checkForUnqualifiedReferenceToNonLocalStaticMember(node); |
| 13393 } | 13435 } |
| 13394 return super.visitSimpleIdentifier(node); | 13436 return super.visitSimpleIdentifier(node); |
| 13395 } | 13437 } |
| 13396 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 13438 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 13397 _isInConstructorInitializer = true; | 13439 _isInConstructorInitializer = true; |
| 13398 try { | 13440 try { |
| 13399 return super.visitSuperConstructorInvocation(node); | 13441 return super.visitSuperConstructorInvocation(node); |
| (...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16267 return false; | 16309 return false; |
| 16268 } | 16310 } |
| 16269 if (redirectedConstructor.isConst) { | 16311 if (redirectedConstructor.isConst) { |
| 16270 return false; | 16312 return false; |
| 16271 } | 16313 } |
| 16272 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST
RUCTOR, redirectedConstructorNode, []); | 16314 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST
RUCTOR, redirectedConstructorNode, []); |
| 16273 return true; | 16315 return true; |
| 16274 } | 16316 } |
| 16275 | 16317 |
| 16276 /** | 16318 /** |
| 16277 * This checks if the passed identifier is banned because it is part of the va
riable declaration | |
| 16278 * with the same name. | |
| 16279 * | |
| 16280 * @param node the identifier to evaluate | |
| 16281 * @return `true` if and only if an error code is generated on the passed node | |
| 16282 * @see CompileTimeErrorCode#REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER | |
| 16283 */ | |
| 16284 bool checkForReferenceToDeclaredVariableInInitializer(SimpleIdentifier node) { | |
| 16285 ASTNode parent = node.parent; | |
| 16286 if (parent is PrefixedIdentifier) { | |
| 16287 PrefixedIdentifier prefixedIdentifier = parent as PrefixedIdentifier; | |
| 16288 if (identical(prefixedIdentifier.identifier, node)) { | |
| 16289 return false; | |
| 16290 } | |
| 16291 } | |
| 16292 if (parent is PropertyAccess) { | |
| 16293 PropertyAccess propertyAccess = parent as PropertyAccess; | |
| 16294 if (identical(propertyAccess.propertyName, node)) { | |
| 16295 return false; | |
| 16296 } | |
| 16297 } | |
| 16298 if (parent is MethodInvocation) { | |
| 16299 MethodInvocation methodInvocation = parent as MethodInvocation; | |
| 16300 if (methodInvocation.target != null && identical(methodInvocation.methodNa
me, node)) { | |
| 16301 return false; | |
| 16302 } | |
| 16303 } | |
| 16304 if (parent is ConstructorName) { | |
| 16305 ConstructorName constructorName = parent as ConstructorName; | |
| 16306 if (identical(constructorName.name, node)) { | |
| 16307 return false; | |
| 16308 } | |
| 16309 } | |
| 16310 if (parent is Label) { | |
| 16311 Label label = parent as Label; | |
| 16312 if (identical(label.label, node)) { | |
| 16313 return false; | |
| 16314 } | |
| 16315 } | |
| 16316 String name = node.name; | |
| 16317 if (!_namesForReferenceToDeclaredVariableInInitializer.contains(name)) { | |
| 16318 return false; | |
| 16319 } | |
| 16320 _errorReporter.reportError2(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIA
BLE_IN_INITIALIZER, node, [name]); | |
| 16321 return true; | |
| 16322 } | |
| 16323 | |
| 16324 /** | |
| 16325 * This checks that the rethrow is inside of a catch clause. | 16319 * This checks that the rethrow is inside of a catch clause. |
| 16326 * | 16320 * |
| 16327 * @param node the rethrow expression to evaluate | 16321 * @param node the rethrow expression to evaluate |
| 16328 * @return `true` if and only if an error code is generated on the passed node | 16322 * @return `true` if and only if an error code is generated on the passed node |
| 16329 * @see CompileTimeErrorCode#RETHROW_OUTSIDE_CATCH | 16323 * @see CompileTimeErrorCode#RETHROW_OUTSIDE_CATCH |
| 16330 */ | 16324 */ |
| 16331 bool checkForRethrowOutsideCatch(RethrowExpression node) { | 16325 bool checkForRethrowOutsideCatch(RethrowExpression node) { |
| 16332 if (!_isInCatchClause) { | 16326 if (!_isInCatchClause) { |
| 16333 _errorReporter.reportError2(CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, no
de, []); | 16327 _errorReporter.reportError2(CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, no
de, []); |
| 16334 return true; | 16328 return true; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16966 ASTNode parent = node.parent; | 16960 ASTNode parent = node.parent; |
| 16967 if (parent is ConstructorName || parent is MethodInvocation || parent is Pro
pertyAccess || parent is SuperConstructorInvocation) { | 16961 if (parent is ConstructorName || parent is MethodInvocation || parent is Pro
pertyAccess || parent is SuperConstructorInvocation) { |
| 16968 return true; | 16962 return true; |
| 16969 } | 16963 } |
| 16970 if (parent is PrefixedIdentifier && identical(((parent as PrefixedIdentifier
)).identifier, node)) { | 16964 if (parent is PrefixedIdentifier && identical(((parent as PrefixedIdentifier
)).identifier, node)) { |
| 16971 return true; | 16965 return true; |
| 16972 } | 16966 } |
| 16973 if (parent is Annotation && identical(((parent as Annotation)).constructorNa
me, node)) { | 16967 if (parent is Annotation && identical(((parent as Annotation)).constructorNa
me, node)) { |
| 16974 return true; | 16968 return true; |
| 16975 } | 16969 } |
| 16970 if (parent is CommentReference) { |
| 16971 CommentReference commentReference = parent as CommentReference; |
| 16972 if (commentReference.newKeyword != null) { |
| 16973 return true; |
| 16974 } |
| 16975 } |
| 16976 return false; | 16976 return false; |
| 16977 } | 16977 } |
| 16978 | 16978 |
| 16979 /** | 16979 /** |
| 16980 * Return `true` iff the passed [ClassElement] has a concrete implementation o
f the | 16980 * Return `true` iff the passed [ClassElement] has a concrete implementation o
f the |
| 16981 * passed accessor name in the superclass chain. | 16981 * passed accessor name in the superclass chain. |
| 16982 */ | 16982 */ |
| 16983 bool memberHasConcreteAccessorImplementationInSuperclassChain(ClassElement cla
ssElement, String accessorName, List<ClassElement> superclassChain) { | 16983 bool memberHasConcreteAccessorImplementationInSuperclassChain(ClassElement cla
ssElement, String accessorName, List<ClassElement> superclassChain) { |
| 16984 if (superclassChain.contains(classElement)) { | 16984 if (superclassChain.contains(classElement)) { |
| 16985 return false; | 16985 return false; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17186 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { | 17186 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { |
| 17187 this._type = type; | 17187 this._type = type; |
| 17188 this._message = message; | 17188 this._message = message; |
| 17189 this.correction9 = correction; | 17189 this.correction9 = correction; |
| 17190 } | 17190 } |
| 17191 String get correction => correction9; | 17191 String get correction => correction9; |
| 17192 ErrorSeverity get errorSeverity => _type.severity; | 17192 ErrorSeverity get errorSeverity => _type.severity; |
| 17193 String get message => _message; | 17193 String get message => _message; |
| 17194 ErrorType get type => _type; | 17194 ErrorType get type => _type; |
| 17195 } | 17195 } |
| OLD | NEW |