| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 bool wasInField = _inFieldContext; | 87 bool wasInField = _inFieldContext; |
| 88 _inFieldContext = false; | 88 _inFieldContext = false; |
| 89 try { | 89 try { |
| 90 node.visitChildren(this); | 90 node.visitChildren(this); |
| 91 } finally { | 91 } finally { |
| 92 _inFieldContext = wasInField; | 92 _inFieldContext = wasInField; |
| 93 } | 93 } |
| 94 return null; | 94 return null; |
| 95 } | 95 } |
| 96 Object visitCatchClause(CatchClause node) { | 96 Object visitCatchClause(CatchClause node) { |
| 97 SimpleIdentifier exceptionParameter2 = node.exceptionParameter; | 97 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 98 if (exceptionParameter2 != null) { | 98 if (exceptionParameter != null) { |
| 99 LocalVariableElementImpl exception = new LocalVariableElementImpl(exceptio
nParameter2); | 99 LocalVariableElementImpl exception = new LocalVariableElementImpl(exceptio
nParameter); |
| 100 _currentHolder.addLocalVariable(exception); | 100 _currentHolder.addLocalVariable(exception); |
| 101 exceptionParameter2.element = exception; | 101 exceptionParameter.element = exception; |
| 102 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter; | 102 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 103 if (stackTraceParameter2 != null) { | 103 if (stackTraceParameter != null) { |
| 104 LocalVariableElementImpl stackTrace = new LocalVariableElementImpl(stack
TraceParameter2); | 104 LocalVariableElementImpl stackTrace = new LocalVariableElementImpl(stack
TraceParameter); |
| 105 _currentHolder.addLocalVariable(stackTrace); | 105 _currentHolder.addLocalVariable(stackTrace); |
| 106 stackTraceParameter2.element = stackTrace; | 106 stackTraceParameter.element = stackTrace; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 return super.visitCatchClause(node); | 109 return super.visitCatchClause(node); |
| 110 } | 110 } |
| 111 Object visitClassDeclaration(ClassDeclaration node) { | 111 Object visitClassDeclaration(ClassDeclaration node) { |
| 112 ElementHolder holder = new ElementHolder(); | 112 ElementHolder holder = new ElementHolder(); |
| 113 _isValidMixin = true; | 113 _isValidMixin = true; |
| 114 visitChildren(holder, node); | 114 visitChildren(holder, node); |
| 115 SimpleIdentifier className = node.name; | 115 SimpleIdentifier className = node.name; |
| 116 ClassElementImpl element = new ClassElementImpl(className); | 116 ClassElementImpl element = new ClassElementImpl(className); |
| 117 List<TypeVariableElement> typeVariables2 = holder.typeVariables; | 117 List<TypeVariableElement> typeVariables = holder.typeVariables; |
| 118 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); | 118 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); |
| 119 interfaceType.typeArguments = createTypeVariableTypes(typeVariables2); | 119 interfaceType.typeArguments = createTypeVariableTypes(typeVariables); |
| 120 element.type = interfaceType; | 120 element.type = interfaceType; |
| 121 List<ConstructorElement> constructors2 = holder.constructors; | 121 List<ConstructorElement> constructors = holder.constructors; |
| 122 if (constructors2.length == 0) { | 122 if (constructors.length == 0) { |
| 123 constructors2 = createDefaultConstructors(interfaceType); | 123 constructors = createDefaultConstructors(interfaceType); |
| 124 } | 124 } |
| 125 element.abstract = node.abstractKeyword != null; | 125 element.abstract = node.abstractKeyword != null; |
| 126 element.accessors = holder.accessors; | 126 element.accessors = holder.accessors; |
| 127 element.constructors = constructors2; | 127 element.constructors = constructors; |
| 128 element.fields = holder.fields; | 128 element.fields = holder.fields; |
| 129 element.methods = holder.methods; | 129 element.methods = holder.methods; |
| 130 element.typeVariables = typeVariables2; | 130 element.typeVariables = typeVariables; |
| 131 element.validMixin = _isValidMixin; | 131 element.validMixin = _isValidMixin; |
| 132 _currentHolder.addType(element); | 132 _currentHolder.addType(element); |
| 133 className.element = element; | 133 className.element = element; |
| 134 return null; | 134 return null; |
| 135 } | 135 } |
| 136 Object visitClassTypeAlias(ClassTypeAlias node) { | 136 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 137 ElementHolder holder = new ElementHolder(); | 137 ElementHolder holder = new ElementHolder(); |
| 138 visitChildren(holder, node); | 138 visitChildren(holder, node); |
| 139 SimpleIdentifier className = node.name; | 139 SimpleIdentifier className = node.name; |
| 140 ClassElementImpl element = new ClassElementImpl(className); | 140 ClassElementImpl element = new ClassElementImpl(className); |
| 141 element.abstract = node.abstractKeyword != null; | 141 element.abstract = node.abstractKeyword != null; |
| 142 element.typedef = true; | 142 element.typedef = true; |
| 143 List<TypeVariableElement> typeVariables2 = holder.typeVariables; | 143 List<TypeVariableElement> typeVariables = holder.typeVariables; |
| 144 element.typeVariables = typeVariables2; | 144 element.typeVariables = typeVariables; |
| 145 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); | 145 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); |
| 146 interfaceType.typeArguments = createTypeVariableTypes(typeVariables2); | 146 interfaceType.typeArguments = createTypeVariableTypes(typeVariables); |
| 147 element.type = interfaceType; | 147 element.type = interfaceType; |
| 148 element.constructors = createDefaultConstructors(interfaceType); | 148 element.constructors = createDefaultConstructors(interfaceType); |
| 149 _currentHolder.addType(element); | 149 _currentHolder.addType(element); |
| 150 className.element = element; | 150 className.element = element; |
| 151 return null; | 151 return null; |
| 152 } | 152 } |
| 153 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 153 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 154 _isValidMixin = false; | 154 _isValidMixin = false; |
| 155 ElementHolder holder = new ElementHolder(); | 155 ElementHolder holder = new ElementHolder(); |
| 156 bool wasInFunction = _inFunction; | 156 bool wasInFunction = _inFunction; |
| 157 _inFunction = true; | 157 _inFunction = true; |
| 158 try { | 158 try { |
| 159 visitChildren(holder, node); | 159 visitChildren(holder, node); |
| 160 } finally { | 160 } finally { |
| 161 _inFunction = wasInFunction; | 161 _inFunction = wasInFunction; |
| 162 } | 162 } |
| 163 SimpleIdentifier constructorName = node.name; | 163 SimpleIdentifier constructorName = node.name; |
| 164 ConstructorElementImpl element = new ConstructorElementImpl(constructorName)
; | 164 ConstructorElementImpl element = new ConstructorElementImpl(constructorName)
; |
| 165 if (node.factoryKeyword != null) { | 165 if (node.factoryKeyword != null) { |
| 166 element.factory = true; | 166 element.factory = true; |
| 167 } | 167 } |
| 168 element.functions = holder.functions; | 168 element.functions = holder.functions; |
| 169 element.labels = holder.labels; | 169 element.labels = holder.labels; |
| 170 element.localVariables = holder.localVariables; | 170 element.localVariables = holder.localVariables; |
| 171 element.parameters = holder.parameters; | 171 element.parameters = holder.parameters; |
| 172 element.const2 = node.constKeyword != null; | 172 element.const2 = node.constKeyword != null; |
| 173 _currentHolder.addConstructor(element); | 173 _currentHolder.addConstructor(element); |
| 174 node.element = element; | 174 node.element = element; |
| 175 if (constructorName == null) { | 175 if (constructorName == null) { |
| 176 Identifier returnType2 = node.returnType; | 176 Identifier returnType = node.returnType; |
| 177 if (returnType2 != null) { | 177 if (returnType != null) { |
| 178 element.nameOffset = returnType2.offset; | 178 element.nameOffset = returnType.offset; |
| 179 } | 179 } |
| 180 } else { | 180 } else { |
| 181 constructorName.element = element; | 181 constructorName.element = element; |
| 182 } | 182 } |
| 183 return null; | 183 return null; |
| 184 } | 184 } |
| 185 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 185 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 186 SimpleIdentifier variableName = node.identifier; | 186 SimpleIdentifier variableName = node.identifier; |
| 187 sc.Token keyword2 = node.keyword; | 187 sc.Token keyword = node.keyword; |
| 188 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); | 188 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); |
| 189 ForEachStatement statement = node.parent as ForEachStatement; | 189 ForEachStatement statement = node.parent as ForEachStatement; |
| 190 int declarationEnd = node.offset + node.length; | 190 int declarationEnd = node.offset + node.length; |
| 191 int statementEnd = statement.offset + statement.length; | 191 int statementEnd = statement.offset + statement.length; |
| 192 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); | 192 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); |
| 193 element.const3 = matches(keyword2, sc.Keyword.CONST); | 193 element.const3 = matches(keyword, sc.Keyword.CONST); |
| 194 element.final2 = matches(keyword2, sc.Keyword.FINAL); | 194 element.final2 = matches(keyword, sc.Keyword.FINAL); |
| 195 _currentHolder.addLocalVariable(element); | 195 _currentHolder.addLocalVariable(element); |
| 196 variableName.element = element; | 196 variableName.element = element; |
| 197 return super.visitDeclaredIdentifier(node); | 197 return super.visitDeclaredIdentifier(node); |
| 198 } | 198 } |
| 199 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 199 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 200 ElementHolder holder = new ElementHolder(); | 200 ElementHolder holder = new ElementHolder(); |
| 201 visit(holder, node.defaultValue); | 201 visit(holder, node.defaultValue); |
| 202 FunctionElementImpl initializer = new FunctionElementImpl(); | 202 FunctionElementImpl initializer = new FunctionElementImpl(); |
| 203 initializer.functions = holder.functions; | 203 initializer.functions = holder.functions; |
| 204 initializer.labels = holder.labels; | 204 initializer.labels = holder.labels; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); | 339 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 340 element.type = type; | 340 element.type = type; |
| 341 _currentHolder.addFunction(element); | 341 _currentHolder.addFunction(element); |
| 342 node.element = element; | 342 node.element = element; |
| 343 return null; | 343 return null; |
| 344 } | 344 } |
| 345 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 345 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 346 ElementHolder holder = new ElementHolder(); | 346 ElementHolder holder = new ElementHolder(); |
| 347 visitChildren(holder, node); | 347 visitChildren(holder, node); |
| 348 SimpleIdentifier aliasName = node.name; | 348 SimpleIdentifier aliasName = node.name; |
| 349 List<ParameterElement> parameters2 = holder.parameters; | 349 List<ParameterElement> parameters = holder.parameters; |
| 350 List<TypeVariableElement> typeVariables2 = holder.typeVariables; | 350 List<TypeVariableElement> typeVariables = holder.typeVariables; |
| 351 FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(alia
sName); | 351 FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(alia
sName); |
| 352 element.parameters = parameters2; | 352 element.parameters = parameters; |
| 353 element.typeVariables = typeVariables2; | 353 element.typeVariables = typeVariables; |
| 354 FunctionTypeImpl type = new FunctionTypeImpl.con2(element); | 354 FunctionTypeImpl type = new FunctionTypeImpl.con2(element); |
| 355 type.typeArguments = createTypeVariableTypes(typeVariables2); | 355 type.typeArguments = createTypeVariableTypes(typeVariables); |
| 356 element.type = type; | 356 element.type = type; |
| 357 _currentHolder.addTypeAlias(element); | 357 _currentHolder.addTypeAlias(element); |
| 358 aliasName.element = element; | 358 aliasName.element = element; |
| 359 return null; | 359 return null; |
| 360 } | 360 } |
| 361 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 361 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 362 if (node.parent is! DefaultFormalParameter) { | 362 if (node.parent is! DefaultFormalParameter) { |
| 363 SimpleIdentifier parameterName = node.identifier; | 363 SimpleIdentifier parameterName = node.identifier; |
| 364 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); | 364 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); |
| 365 parameter.parameterKind = node.kind; | 365 parameter.parameterKind = node.kind; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 383 } | 383 } |
| 384 Object visitMethodDeclaration(MethodDeclaration node) { | 384 Object visitMethodDeclaration(MethodDeclaration node) { |
| 385 ElementHolder holder = new ElementHolder(); | 385 ElementHolder holder = new ElementHolder(); |
| 386 bool wasInFunction = _inFunction; | 386 bool wasInFunction = _inFunction; |
| 387 _inFunction = true; | 387 _inFunction = true; |
| 388 try { | 388 try { |
| 389 visitChildren(holder, node); | 389 visitChildren(holder, node); |
| 390 } finally { | 390 } finally { |
| 391 _inFunction = wasInFunction; | 391 _inFunction = wasInFunction; |
| 392 } | 392 } |
| 393 bool isStatic2 = node.isStatic(); | 393 bool isStatic = node.isStatic(); |
| 394 sc.Token property = node.propertyKeyword; | 394 sc.Token property = node.propertyKeyword; |
| 395 if (property == null) { | 395 if (property == null) { |
| 396 SimpleIdentifier methodName = node.name; | 396 SimpleIdentifier methodName = node.name; |
| 397 String nameOfMethod = methodName.name; | 397 String nameOfMethod = methodName.name; |
| 398 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { | 398 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { |
| 399 nameOfMethod = "unary-"; | 399 nameOfMethod = "unary-"; |
| 400 } | 400 } |
| 401 MethodElementImpl element = new MethodElementImpl.con2(nameOfMethod, metho
dName.offset); | 401 MethodElementImpl element = new MethodElementImpl.con2(nameOfMethod, metho
dName.offset); |
| 402 element.abstract = node.isAbstract(); | 402 element.abstract = node.isAbstract(); |
| 403 element.functions = holder.functions; | 403 element.functions = holder.functions; |
| 404 element.labels = holder.labels; | 404 element.labels = holder.labels; |
| 405 element.localVariables = holder.localVariables; | 405 element.localVariables = holder.localVariables; |
| 406 element.parameters = holder.parameters; | 406 element.parameters = holder.parameters; |
| 407 element.static = isStatic2; | 407 element.static = isStatic; |
| 408 _currentHolder.addMethod(element); | 408 _currentHolder.addMethod(element); |
| 409 methodName.element = element; | 409 methodName.element = element; |
| 410 } else { | 410 } else { |
| 411 SimpleIdentifier propertyNameNode = node.name; | 411 SimpleIdentifier propertyNameNode = node.name; |
| 412 String propertyName = propertyNameNode.name; | 412 String propertyName = propertyNameNode.name; |
| 413 FieldElementImpl field = _currentHolder.getField(propertyName) as FieldEle
mentImpl; | 413 FieldElementImpl field = _currentHolder.getField(propertyName) as FieldEle
mentImpl; |
| 414 if (field == null) { | 414 if (field == null) { |
| 415 field = new FieldElementImpl.con2(node.name.name); | 415 field = new FieldElementImpl.con2(node.name.name); |
| 416 field.final2 = true; | 416 field.final2 = true; |
| 417 field.static = isStatic2; | 417 field.static = isStatic; |
| 418 _currentHolder.addField(field); | 418 _currentHolder.addField(field); |
| 419 } | 419 } |
| 420 if (matches(property, sc.Keyword.GET)) { | 420 if (matches(property, sc.Keyword.GET)) { |
| 421 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con
1(propertyNameNode); | 421 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con
1(propertyNameNode); |
| 422 getter.functions = holder.functions; | 422 getter.functions = holder.functions; |
| 423 getter.labels = holder.labels; | 423 getter.labels = holder.labels; |
| 424 getter.localVariables = holder.localVariables; | 424 getter.localVariables = holder.localVariables; |
| 425 getter.variable = field; | 425 getter.variable = field; |
| 426 getter.abstract = node.body is EmptyFunctionBody && node.externalKeyword
== null; | 426 getter.abstract = node.body is EmptyFunctionBody && node.externalKeyword
== null; |
| 427 getter.getter = true; | 427 getter.getter = true; |
| 428 getter.static = isStatic2; | 428 getter.static = isStatic; |
| 429 field.getter = getter; | 429 field.getter = getter; |
| 430 _currentHolder.addAccessor(getter); | 430 _currentHolder.addAccessor(getter); |
| 431 propertyNameNode.element = getter; | 431 propertyNameNode.element = getter; |
| 432 } else { | 432 } else { |
| 433 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con
1(propertyNameNode); | 433 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con
1(propertyNameNode); |
| 434 setter.functions = holder.functions; | 434 setter.functions = holder.functions; |
| 435 setter.labels = holder.labels; | 435 setter.labels = holder.labels; |
| 436 setter.localVariables = holder.localVariables; | 436 setter.localVariables = holder.localVariables; |
| 437 setter.parameters = holder.parameters; | 437 setter.parameters = holder.parameters; |
| 438 setter.variable = field; | 438 setter.variable = field; |
| 439 setter.abstract = node.body is EmptyFunctionBody && !matches(node.extern
alKeyword, sc.Keyword.EXTERNAL); | 439 setter.abstract = node.body is EmptyFunctionBody && !matches(node.extern
alKeyword, sc.Keyword.EXTERNAL); |
| 440 setter.setter = true; | 440 setter.setter = true; |
| 441 setter.static = isStatic2; | 441 setter.static = isStatic; |
| 442 field.setter = setter; | 442 field.setter = setter; |
| 443 field.final2 = false; | 443 field.final2 = false; |
| 444 _currentHolder.addAccessor(setter); | 444 _currentHolder.addAccessor(setter); |
| 445 propertyNameNode.element = setter; | 445 propertyNameNode.element = setter; |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 return null; | 448 return null; |
| 449 } | 449 } |
| 450 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 450 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 451 if (node.parent is! DefaultFormalParameter) { | 451 if (node.parent is! DefaultFormalParameter) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Object visitTypeParameter(TypeParameter node) { | 484 Object visitTypeParameter(TypeParameter node) { |
| 485 SimpleIdentifier parameterName = node.name; | 485 SimpleIdentifier parameterName = node.name; |
| 486 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName)
; | 486 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName)
; |
| 487 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | 487 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); |
| 488 element.type = type; | 488 element.type = type; |
| 489 _currentHolder.addTypeVariable(element); | 489 _currentHolder.addTypeVariable(element); |
| 490 parameterName.element = element; | 490 parameterName.element = element; |
| 491 return super.visitTypeParameter(node); | 491 return super.visitTypeParameter(node); |
| 492 } | 492 } |
| 493 Object visitVariableDeclaration(VariableDeclaration node) { | 493 Object visitVariableDeclaration(VariableDeclaration node) { |
| 494 sc.Token keyword2 = ((node.parent as VariableDeclarationList)).keyword; | 494 sc.Token keyword = ((node.parent as VariableDeclarationList)).keyword; |
| 495 bool isConst = matches(keyword2, sc.Keyword.CONST); | 495 bool isConst = matches(keyword, sc.Keyword.CONST); |
| 496 bool isFinal = matches(keyword2, sc.Keyword.FINAL); | 496 bool isFinal = matches(keyword, sc.Keyword.FINAL); |
| 497 bool hasInitializer = node.initializer != null; | 497 bool hasInitializer = node.initializer != null; |
| 498 VariableElementImpl element; | 498 VariableElementImpl element; |
| 499 if (_inFieldContext) { | 499 if (_inFieldContext) { |
| 500 SimpleIdentifier fieldName = node.name; | 500 SimpleIdentifier fieldName = node.name; |
| 501 FieldElementImpl field; | 501 FieldElementImpl field; |
| 502 if (isConst && hasInitializer) { | 502 if (isConst && hasInitializer) { |
| 503 field = new ConstFieldElementImpl(fieldName); | 503 field = new ConstFieldElementImpl(fieldName); |
| 504 } else { | 504 } else { |
| 505 field = new FieldElementImpl.con1(fieldName); | 505 field = new FieldElementImpl.con1(fieldName); |
| 506 } | 506 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 return typeArguments; | 598 return typeArguments; |
| 599 } | 599 } |
| 600 | 600 |
| 601 /** | 601 /** |
| 602 * Return the body of the function that contains the given parameter, or {@cod
e null} if no | 602 * Return the body of the function that contains the given parameter, or {@cod
e null} if no |
| 603 * function body could be found. | 603 * function body could be found. |
| 604 * @param node the parameter contained in the function whose body is to be ret
urned | 604 * @param node the parameter contained in the function whose body is to be ret
urned |
| 605 * @return the body of the function that contains the given parameter | 605 * @return the body of the function that contains the given parameter |
| 606 */ | 606 */ |
| 607 FunctionBody getFunctionBody(FormalParameter node) { | 607 FunctionBody getFunctionBody(FormalParameter node) { |
| 608 ASTNode parent2 = node.parent; | 608 ASTNode parent = node.parent; |
| 609 while (parent2 != null) { | 609 while (parent != null) { |
| 610 if (parent2 is FunctionExpression) { | 610 if (parent is FunctionExpression) { |
| 611 return ((parent2 as FunctionExpression)).body; | 611 return ((parent as FunctionExpression)).body; |
| 612 } else if (parent2 is MethodDeclaration) { | 612 } else if (parent is MethodDeclaration) { |
| 613 return ((parent2 as MethodDeclaration)).body; | 613 return ((parent as MethodDeclaration)).body; |
| 614 } | 614 } |
| 615 parent2 = parent2.parent; | 615 parent = parent.parent; |
| 616 } | 616 } |
| 617 return null; | 617 return null; |
| 618 } | 618 } |
| 619 | 619 |
| 620 /** | 620 /** |
| 621 * Return {@code true} if the given token is a token for the given keyword. | 621 * Return {@code true} if the given token is a token for the given keyword. |
| 622 * @param token the token being tested | 622 * @param token the token being tested |
| 623 * @param keyword the keyword being tested for | 623 * @param keyword the keyword being tested for |
| 624 * @return {@code true} if the given token is a token for the given keyword | 624 * @return {@code true} if the given token is a token for the given keyword |
| 625 */ | 625 */ |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 } | 922 } |
| 923 _parentNodes.add(node); | 923 _parentNodes.add(node); |
| 924 try { | 924 try { |
| 925 if (isScriptNode(node)) { | 925 if (isScriptNode(node)) { |
| 926 Source htmlSource = _htmlElement.source; | 926 Source htmlSource = _htmlElement.source; |
| 927 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node); | 927 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node); |
| 928 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribu
te.text; | 928 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribu
te.text; |
| 929 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePa
th == null) { | 929 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePa
th == null) { |
| 930 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementIm
pl(node); | 930 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementIm
pl(node); |
| 931 String contents = node.content; | 931 String contents = node.content; |
| 932 int attributeEnd2 = node.attributeEnd.end; | 932 int attributeEnd = node.attributeEnd.end; |
| 933 LineInfo_Location location = _lineInfo.getLocation(attributeEnd2); | 933 LineInfo_Location location = _lineInfo.getLocation(attributeEnd); |
| 934 sc.StringScanner scanner = new sc.StringScanner(htmlSource, contents,
_errorListener); | 934 sc.StringScanner scanner = new sc.StringScanner(htmlSource, contents,
_errorListener); |
| 935 scanner.setSourceStart(location.lineNumber, location.columnNumber, att
ributeEnd2); | 935 scanner.setSourceStart(location.lineNumber, location.columnNumber, att
ributeEnd); |
| 936 sc.Token firstToken = scanner.tokenize(); | 936 sc.Token firstToken = scanner.tokenize(); |
| 937 List<int> lineStarts2 = scanner.lineStarts; | 937 List<int> lineStarts = scanner.lineStarts; |
| 938 Parser parser = new Parser(htmlSource, _errorListener); | 938 Parser parser = new Parser(htmlSource, _errorListener); |
| 939 CompilationUnit unit = parser.parseCompilationUnit(firstToken); | 939 CompilationUnit unit = parser.parseCompilationUnit(firstToken); |
| 940 unit.lineInfo = new LineInfo(lineStarts2); | 940 unit.lineInfo = new LineInfo(lineStarts); |
| 941 try { | 941 try { |
| 942 LibraryResolver resolver = new LibraryResolver(_context); | 942 LibraryResolver resolver = new LibraryResolver(_context); |
| 943 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSou
rce, unit, true) as LibraryElementImpl; | 943 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSou
rce, unit, true) as LibraryElementImpl; |
| 944 script.scriptLibrary = library; | 944 script.scriptLibrary = library; |
| 945 _resolvedLibraries.addAll(resolver.resolvedLibraries); | 945 _resolvedLibraries.addAll(resolver.resolvedLibraries); |
| 946 _errorListener.addAll(resolver.errorListener); | 946 _errorListener.addAll(resolver.errorListener); |
| 947 } on AnalysisException catch (exception) { | 947 } on AnalysisException catch (exception) { |
| 948 AnalysisEngine.instance.logger.logError3(exception); | 948 AnalysisEngine.instance.logger.logError3(exception); |
| 949 } | 949 } |
| 950 _scripts.add(script); | 950 _scripts.add(script); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 * element. | 1062 * element. |
| 1063 * @param unit the compilation unit to be resolved | 1063 * @param unit the compilation unit to be resolved |
| 1064 * @param element the root of the element model used to resolve the AST nodes | 1064 * @param element the root of the element model used to resolve the AST nodes |
| 1065 */ | 1065 */ |
| 1066 void resolve(CompilationUnit unit, CompilationUnitElement element2) { | 1066 void resolve(CompilationUnit unit, CompilationUnitElement element2) { |
| 1067 _enclosingUnit = element2; | 1067 _enclosingUnit = element2; |
| 1068 unit.element = element2; | 1068 unit.element = element2; |
| 1069 unit.accept(this); | 1069 unit.accept(this); |
| 1070 } | 1070 } |
| 1071 Object visitCatchClause(CatchClause node) { | 1071 Object visitCatchClause(CatchClause node) { |
| 1072 SimpleIdentifier exceptionParameter2 = node.exceptionParameter; | 1072 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 1073 if (exceptionParameter2 != null) { | 1073 if (exceptionParameter != null) { |
| 1074 List<LocalVariableElement> localVariables2 = _enclosingExecutable.localVar
iables; | 1074 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; |
| 1075 find3(localVariables2, exceptionParameter2); | 1075 find3(localVariables, exceptionParameter); |
| 1076 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter; | 1076 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 1077 if (stackTraceParameter2 != null) { | 1077 if (stackTraceParameter != null) { |
| 1078 find3(localVariables2, stackTraceParameter2); | 1078 find3(localVariables, stackTraceParameter); |
| 1079 } | 1079 } |
| 1080 } | 1080 } |
| 1081 return super.visitCatchClause(node); | 1081 return super.visitCatchClause(node); |
| 1082 } | 1082 } |
| 1083 Object visitClassDeclaration(ClassDeclaration node) { | 1083 Object visitClassDeclaration(ClassDeclaration node) { |
| 1084 ClassElement outerClass = _enclosingClass; | 1084 ClassElement outerClass = _enclosingClass; |
| 1085 try { | 1085 try { |
| 1086 SimpleIdentifier className = node.name; | 1086 SimpleIdentifier className = node.name; |
| 1087 _enclosingClass = find3(_enclosingUnit.types, className); | 1087 _enclosingClass = find3(_enclosingUnit.types, className); |
| 1088 return super.visitClassDeclaration(node); | 1088 return super.visitClassDeclaration(node); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 1124 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 1125 SimpleIdentifier parameterName = node.parameter.identifier; | 1125 SimpleIdentifier parameterName = node.parameter.identifier; |
| 1126 ParameterElement element = null; | 1126 ParameterElement element = null; |
| 1127 if (_enclosingExecutable != null) { | 1127 if (_enclosingExecutable != null) { |
| 1128 element = find3(_enclosingExecutable.parameters, parameterName); | 1128 element = find3(_enclosingExecutable.parameters, parameterName); |
| 1129 } else { | 1129 } else { |
| 1130 PrintStringWriter writer = new PrintStringWriter(); | 1130 PrintStringWriter writer = new PrintStringWriter(); |
| 1131 writer.println("Invalid state found in the Analysis Engine:"); | 1131 writer.println("Invalid state found in the Analysis Engine:"); |
| 1132 writer.println("DeclarationResolver.visitDefaultFormalParameter() is visit
ing a parameter that does not appear to be in a method or function."); | 1132 writer.println("DeclarationResolver.visitDefaultFormalParameter() is visit
ing a parameter that does not appear to be in a method or function."); |
| 1133 writer.println("Ancestors:"); | 1133 writer.println("Ancestors:"); |
| 1134 ASTNode parent2 = node.parent; | 1134 ASTNode parent = node.parent; |
| 1135 while (parent2 != null) { | 1135 while (parent != null) { |
| 1136 writer.println(parent2.runtimeType.toString()); | 1136 writer.println(parent.runtimeType.toString()); |
| 1137 writer.println("---------"); | 1137 writer.println("---------"); |
| 1138 parent2 = parent2.parent; | 1138 parent = parent.parent; |
| 1139 } | 1139 } |
| 1140 AnalysisEngine.instance.logger.logError2(writer.toString(), new AnalysisEx
ception()); | 1140 AnalysisEngine.instance.logger.logError2(writer.toString(), new AnalysisEx
ception()); |
| 1141 } | 1141 } |
| 1142 Expression defaultValue2 = node.defaultValue; | 1142 Expression defaultValue = node.defaultValue; |
| 1143 if (defaultValue2 != null) { | 1143 if (defaultValue != null) { |
| 1144 ExecutableElement outerExecutable = _enclosingExecutable; | 1144 ExecutableElement outerExecutable = _enclosingExecutable; |
| 1145 try { | 1145 try { |
| 1146 if (element == null) { | 1146 if (element == null) { |
| 1147 } else { | 1147 } else { |
| 1148 _enclosingExecutable = element.initializer; | 1148 _enclosingExecutable = element.initializer; |
| 1149 } | 1149 } |
| 1150 defaultValue2.accept(this); | 1150 defaultValue.accept(this); |
| 1151 } finally { | 1151 } finally { |
| 1152 _enclosingExecutable = outerExecutable; | 1152 _enclosingExecutable = outerExecutable; |
| 1153 } | 1153 } |
| 1154 } | 1154 } |
| 1155 ParameterElement outerParameter = _enclosingParameter; | 1155 ParameterElement outerParameter = _enclosingParameter; |
| 1156 try { | 1156 try { |
| 1157 _enclosingParameter = element; | 1157 _enclosingParameter = element; |
| 1158 return super.visitDefaultFormalParameter(node); | 1158 return super.visitDefaultFormalParameter(node); |
| 1159 } finally { | 1159 } finally { |
| 1160 _enclosingParameter = outerParameter; | 1160 _enclosingParameter = outerParameter; |
| 1161 } | 1161 } |
| 1162 } | 1162 } |
| 1163 Object visitExportDirective(ExportDirective node) { | 1163 Object visitExportDirective(ExportDirective node) { |
| 1164 String uri2 = getStringValue(node.uri); | 1164 String uri = getStringValue(node.uri); |
| 1165 if (uri2 != null) { | 1165 if (uri != null) { |
| 1166 LibraryElement library2 = _enclosingUnit.library; | 1166 LibraryElement library = _enclosingUnit.library; |
| 1167 ExportElement exportElement = find5(library2.exports, _enclosingUnit.conte
xt.sourceFactory.resolveUri(_enclosingUnit.source, uri2)); | 1167 ExportElement exportElement = find5(library.exports, _enclosingUnit.contex
t.sourceFactory.resolveUri(_enclosingUnit.source, uri)); |
| 1168 node.element = exportElement; | 1168 node.element = exportElement; |
| 1169 } | 1169 } |
| 1170 return super.visitExportDirective(node); | 1170 return super.visitExportDirective(node); |
| 1171 } | 1171 } |
| 1172 Object visitFieldFormalParameter(FieldFormalParameter node) { | 1172 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 1173 if (node.parent is! DefaultFormalParameter) { | 1173 if (node.parent is! DefaultFormalParameter) { |
| 1174 SimpleIdentifier parameterName = node.identifier; | 1174 SimpleIdentifier parameterName = node.identifier; |
| 1175 ParameterElement element = find3(_enclosingExecutable.parameters, paramete
rName); | 1175 ParameterElement element = find3(_enclosingExecutable.parameters, paramete
rName); |
| 1176 ParameterElement outerParameter = _enclosingParameter; | 1176 ParameterElement outerParameter = _enclosingParameter; |
| 1177 try { | 1177 try { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 _enclosingParameter = element; | 1241 _enclosingParameter = element; |
| 1242 return super.visitFunctionTypedFormalParameter(node); | 1242 return super.visitFunctionTypedFormalParameter(node); |
| 1243 } finally { | 1243 } finally { |
| 1244 _enclosingParameter = outerParameter; | 1244 _enclosingParameter = outerParameter; |
| 1245 } | 1245 } |
| 1246 } else { | 1246 } else { |
| 1247 return super.visitFunctionTypedFormalParameter(node); | 1247 return super.visitFunctionTypedFormalParameter(node); |
| 1248 } | 1248 } |
| 1249 } | 1249 } |
| 1250 Object visitImportDirective(ImportDirective node) { | 1250 Object visitImportDirective(ImportDirective node) { |
| 1251 String uri2 = getStringValue(node.uri); | 1251 String uri = getStringValue(node.uri); |
| 1252 if (uri2 != null) { | 1252 if (uri != null) { |
| 1253 LibraryElement library2 = _enclosingUnit.library; | 1253 LibraryElement library = _enclosingUnit.library; |
| 1254 ImportElement importElement = find6(library2.imports, _enclosingUnit.conte
xt.sourceFactory.resolveUri(_enclosingUnit.source, uri2), node.prefix); | 1254 ImportElement importElement = find6(library.imports, _enclosingUnit.contex
t.sourceFactory.resolveUri(_enclosingUnit.source, uri), node.prefix); |
| 1255 node.element = importElement; | 1255 node.element = importElement; |
| 1256 } | 1256 } |
| 1257 return super.visitImportDirective(node); | 1257 return super.visitImportDirective(node); |
| 1258 } | 1258 } |
| 1259 Object visitLabeledStatement(LabeledStatement node) { | 1259 Object visitLabeledStatement(LabeledStatement node) { |
| 1260 for (Label label in node.labels) { | 1260 for (Label label in node.labels) { |
| 1261 SimpleIdentifier labelName = label.label; | 1261 SimpleIdentifier labelName = label.label; |
| 1262 find3(_enclosingExecutable.labels, labelName); | 1262 find3(_enclosingExecutable.labels, labelName); |
| 1263 } | 1263 } |
| 1264 return super.visitLabeledStatement(node); | 1264 return super.visitLabeledStatement(node); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1286 methodName.element = accessor; | 1286 methodName.element = accessor; |
| 1287 } | 1287 } |
| 1288 _enclosingExecutable = accessor; | 1288 _enclosingExecutable = accessor; |
| 1289 } | 1289 } |
| 1290 return super.visitMethodDeclaration(node); | 1290 return super.visitMethodDeclaration(node); |
| 1291 } finally { | 1291 } finally { |
| 1292 _enclosingExecutable = outerExecutable; | 1292 _enclosingExecutable = outerExecutable; |
| 1293 } | 1293 } |
| 1294 } | 1294 } |
| 1295 Object visitPartDirective(PartDirective node) { | 1295 Object visitPartDirective(PartDirective node) { |
| 1296 String uri2 = getStringValue(node.uri); | 1296 String uri = getStringValue(node.uri); |
| 1297 if (uri2 != null) { | 1297 if (uri != null) { |
| 1298 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri2); | 1298 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri); |
| 1299 node.element = find(_enclosingUnit.library.parts, partSource); | 1299 node.element = find(_enclosingUnit.library.parts, partSource); |
| 1300 } | 1300 } |
| 1301 return super.visitPartDirective(node); | 1301 return super.visitPartDirective(node); |
| 1302 } | 1302 } |
| 1303 Object visitPartOfDirective(PartOfDirective node) { | 1303 Object visitPartOfDirective(PartOfDirective node) { |
| 1304 node.element = _enclosingUnit.library; | 1304 node.element = _enclosingUnit.library; |
| 1305 return super.visitPartOfDirective(node); | 1305 return super.visitPartOfDirective(node); |
| 1306 } | 1306 } |
| 1307 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 1307 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 1308 if (node.parent is! DefaultFormalParameter) { | 1308 if (node.parent is! DefaultFormalParameter) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 SimpleIdentifier variableName = node.name; | 1355 SimpleIdentifier variableName = node.name; |
| 1356 if (_enclosingExecutable != null) { | 1356 if (_enclosingExecutable != null) { |
| 1357 element = find3(_enclosingExecutable.localVariables, variableName); | 1357 element = find3(_enclosingExecutable.localVariables, variableName); |
| 1358 } | 1358 } |
| 1359 if (element == null && _enclosingClass != null) { | 1359 if (element == null && _enclosingClass != null) { |
| 1360 element = find3(_enclosingClass.fields, variableName); | 1360 element = find3(_enclosingClass.fields, variableName); |
| 1361 } | 1361 } |
| 1362 if (element == null && _enclosingUnit != null) { | 1362 if (element == null && _enclosingUnit != null) { |
| 1363 element = find3(_enclosingUnit.topLevelVariables, variableName); | 1363 element = find3(_enclosingUnit.topLevelVariables, variableName); |
| 1364 } | 1364 } |
| 1365 Expression initializer2 = node.initializer; | 1365 Expression initializer = node.initializer; |
| 1366 if (initializer2 != null) { | 1366 if (initializer != null) { |
| 1367 ExecutableElement outerExecutable = _enclosingExecutable; | 1367 ExecutableElement outerExecutable = _enclosingExecutable; |
| 1368 try { | 1368 try { |
| 1369 if (element == null) { | 1369 if (element == null) { |
| 1370 } else { | 1370 } else { |
| 1371 _enclosingExecutable = element.initializer; | 1371 _enclosingExecutable = element.initializer; |
| 1372 } | 1372 } |
| 1373 return super.visitVariableDeclaration(node); | 1373 return super.visitVariableDeclaration(node); |
| 1374 } finally { | 1374 } finally { |
| 1375 _enclosingExecutable = outerExecutable; | 1375 _enclosingExecutable = outerExecutable; |
| 1376 } | 1376 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 * names in hide and show combinators that are not defined in the imported libra
ry (which is not an | 1560 * names in hide and show combinators that are not defined in the imported libra
ry (which is not an |
| 1561 * error). | 1561 * error). |
| 1562 * @coverage dart.engine.resolver | 1562 * @coverage dart.engine.resolver |
| 1563 */ | 1563 */ |
| 1564 class ElementResolver extends SimpleASTVisitor<Object> { | 1564 class ElementResolver extends SimpleASTVisitor<Object> { |
| 1565 | 1565 |
| 1566 /** | 1566 /** |
| 1567 * @return {@code true} if the given identifier is the return type of a constr
uctor declaration. | 1567 * @return {@code true} if the given identifier is the return type of a constr
uctor declaration. |
| 1568 */ | 1568 */ |
| 1569 static bool isConstructorReturnType(SimpleIdentifier node) { | 1569 static bool isConstructorReturnType(SimpleIdentifier node) { |
| 1570 ASTNode parent2 = node.parent; | 1570 ASTNode parent = node.parent; |
| 1571 if (parent2 is ConstructorDeclaration) { | 1571 if (parent is ConstructorDeclaration) { |
| 1572 ConstructorDeclaration constructor = parent2 as ConstructorDeclaration; | 1572 ConstructorDeclaration constructor = parent as ConstructorDeclaration; |
| 1573 return identical(constructor.returnType, node); | 1573 return identical(constructor.returnType, node); |
| 1574 } | 1574 } |
| 1575 return false; | 1575 return false; |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 /** | 1578 /** |
| 1579 * @return {@code true} if the given identifier is the return type of a factor
y constructor | 1579 * @return {@code true} if the given identifier is the return type of a factor
y constructor |
| 1580 * declaration. | 1580 * declaration. |
| 1581 */ | 1581 */ |
| 1582 static bool isFactoryConstructorReturnType(SimpleIdentifier node) { | 1582 static bool isFactoryConstructorReturnType(SimpleIdentifier node) { |
| 1583 ASTNode parent2 = node.parent; | 1583 ASTNode parent = node.parent; |
| 1584 if (parent2 is ConstructorDeclaration) { | 1584 if (parent is ConstructorDeclaration) { |
| 1585 ConstructorDeclaration constructor = parent2 as ConstructorDeclaration; | 1585 ConstructorDeclaration constructor = parent as ConstructorDeclaration; |
| 1586 return identical(constructor.returnType, node) && constructor.factoryKeywo
rd != null; | 1586 return identical(constructor.returnType, node) && constructor.factoryKeywo
rd != null; |
| 1587 } | 1587 } |
| 1588 return false; | 1588 return false; |
| 1589 } | 1589 } |
| 1590 | 1590 |
| 1591 /** | 1591 /** |
| 1592 * Checks if the given 'super' expression is used in the valid context. | 1592 * Checks if the given 'super' expression is used in the valid context. |
| 1593 * @param node the 'super' expression to analyze | 1593 * @param node the 'super' expression to analyze |
| 1594 * @return {@code true} if the given 'super' expression is in the valid contex
t | 1594 * @return {@code true} if the given 'super' expression is in the valid contex
t |
| 1595 */ | 1595 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 | 1638 |
| 1639 /** | 1639 /** |
| 1640 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 1640 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
| 1641 * @param resolver the resolver driving this participant | 1641 * @param resolver the resolver driving this participant |
| 1642 */ | 1642 */ |
| 1643 ElementResolver(ResolverVisitor resolver) { | 1643 ElementResolver(ResolverVisitor resolver) { |
| 1644 this._resolver = resolver; | 1644 this._resolver = resolver; |
| 1645 _strictMode = resolver.definingLibrary.context.analysisOptions.strictMode; | 1645 _strictMode = resolver.definingLibrary.context.analysisOptions.strictMode; |
| 1646 } | 1646 } |
| 1647 Object visitAssignmentExpression(AssignmentExpression node) { | 1647 Object visitAssignmentExpression(AssignmentExpression node) { |
| 1648 sc.Token operator2 = node.operator; | 1648 sc.Token operator = node.operator; |
| 1649 sc.TokenType operatorType = operator2.type; | 1649 sc.TokenType operatorType = operator.type; |
| 1650 if (operatorType != sc.TokenType.EQ) { | 1650 if (operatorType != sc.TokenType.EQ) { |
| 1651 operatorType = operatorFromCompoundAssignment(operatorType); | 1651 operatorType = operatorFromCompoundAssignment(operatorType); |
| 1652 Expression leftHandSide2 = node.leftHandSide; | 1652 Expression leftHandSide = node.leftHandSide; |
| 1653 if (leftHandSide2 != null) { | 1653 if (leftHandSide != null) { |
| 1654 String methodName = operatorType.lexeme; | 1654 String methodName = operatorType.lexeme; |
| 1655 Type2 staticType = getStaticType(leftHandSide2); | 1655 Type2 staticType = getStaticType(leftHandSide); |
| 1656 MethodElement staticMethod = lookUpMethod(leftHandSide2, staticType, met
hodName); | 1656 MethodElement staticMethod = lookUpMethod(leftHandSide, staticType, meth
odName); |
| 1657 node.staticElement = staticMethod; | 1657 node.staticElement = staticMethod; |
| 1658 Type2 propagatedType = getPropagatedType(leftHandSide2); | 1658 Type2 propagatedType = getPropagatedType(leftHandSide); |
| 1659 MethodElement propagatedMethod = lookUpMethod(leftHandSide2, propagatedT
ype, methodName); | 1659 MethodElement propagatedMethod = lookUpMethod(leftHandSide, propagatedTy
pe, methodName); |
| 1660 node.element = select3(staticMethod, propagatedMethod); | 1660 node.element = select3(staticMethod, propagatedMethod); |
| 1661 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { | 1661 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { |
| 1662 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operato
r2, [methodName, staticType.displayName]); | 1662 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operato
r, [methodName, staticType.displayName]); |
| 1663 } | 1663 } |
| 1664 } | 1664 } |
| 1665 } | 1665 } |
| 1666 return null; | 1666 return null; |
| 1667 } | 1667 } |
| 1668 Object visitBinaryExpression(BinaryExpression node) { | 1668 Object visitBinaryExpression(BinaryExpression node) { |
| 1669 sc.Token operator2 = node.operator; | 1669 sc.Token operator = node.operator; |
| 1670 if (operator2.isUserDefinableOperator()) { | 1670 if (operator.isUserDefinableOperator()) { |
| 1671 Expression leftOperand2 = node.leftOperand; | 1671 Expression leftOperand = node.leftOperand; |
| 1672 if (leftOperand2 != null) { | 1672 if (leftOperand != null) { |
| 1673 String methodName = operator2.lexeme; | 1673 String methodName = operator.lexeme; |
| 1674 Type2 staticType = getStaticType(leftOperand2); | 1674 Type2 staticType = getStaticType(leftOperand); |
| 1675 MethodElement staticMethod = lookUpMethod(leftOperand2, staticType, meth
odName); | 1675 MethodElement staticMethod = lookUpMethod(leftOperand, staticType, metho
dName); |
| 1676 node.staticElement = staticMethod; | 1676 node.staticElement = staticMethod; |
| 1677 Type2 propagatedType = getPropagatedType(leftOperand2); | 1677 Type2 propagatedType = getPropagatedType(leftOperand); |
| 1678 MethodElement propagatedMethod = lookUpMethod(leftOperand2, propagatedTy
pe, methodName); | 1678 MethodElement propagatedMethod = lookUpMethod(leftOperand, propagatedTyp
e, methodName); |
| 1679 node.element = select3(staticMethod, propagatedMethod); | 1679 node.element = select3(staticMethod, propagatedMethod); |
| 1680 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { | 1680 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { |
| 1681 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, opera
tor2, [methodName, staticType.displayName]); | 1681 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, opera
tor, [methodName, staticType.displayName]); |
| 1682 } | 1682 } |
| 1683 } | 1683 } |
| 1684 } | 1684 } |
| 1685 return null; | 1685 return null; |
| 1686 } | 1686 } |
| 1687 Object visitBreakStatement(BreakStatement node) { | 1687 Object visitBreakStatement(BreakStatement node) { |
| 1688 SimpleIdentifier labelNode = node.label; | 1688 SimpleIdentifier labelNode = node.label; |
| 1689 LabelElementImpl labelElement = lookupLabel(node, labelNode); | 1689 LabelElementImpl labelElement = lookupLabel(node, labelNode); |
| 1690 if (labelElement != null && labelElement.isOnSwitchMember()) { | 1690 if (labelElement != null && labelElement.isOnSwitchMember()) { |
| 1691 _resolver.reportError(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labe
lNode, []); | 1691 _resolver.reportError(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labe
lNode, []); |
| 1692 } | 1692 } |
| 1693 return null; | 1693 return null; |
| 1694 } | 1694 } |
| 1695 Object visitClassDeclaration(ClassDeclaration node) { | 1695 Object visitClassDeclaration(ClassDeclaration node) { |
| 1696 setMetadata(node.element, node); | 1696 setMetadata(node.element, node); |
| 1697 return null; | 1697 return null; |
| 1698 } | 1698 } |
| 1699 Object visitClassTypeAlias(ClassTypeAlias node) { | 1699 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 1700 setMetadata(node.element, node); | 1700 setMetadata(node.element, node); |
| 1701 return null; | 1701 return null; |
| 1702 } | 1702 } |
| 1703 Object visitCommentReference(CommentReference node) { | 1703 Object visitCommentReference(CommentReference node) { |
| 1704 Identifier identifier2 = node.identifier; | 1704 Identifier identifier = node.identifier; |
| 1705 if (identifier2 is SimpleIdentifier) { | 1705 if (identifier is SimpleIdentifier) { |
| 1706 SimpleIdentifier simpleIdentifier = identifier2 as SimpleIdentifier; | 1706 SimpleIdentifier simpleIdentifier = identifier as SimpleIdentifier; |
| 1707 Element element = resolveSimpleIdentifier(simpleIdentifier); | 1707 Element element = resolveSimpleIdentifier(simpleIdentifier); |
| 1708 if (element == null) { | 1708 if (element == null) { |
| 1709 element = findImportWithoutPrefix(simpleIdentifier); | 1709 element = findImportWithoutPrefix(simpleIdentifier); |
| 1710 if (element is MultiplyDefinedElement) { | 1710 if (element is MultiplyDefinedElement) { |
| 1711 element = null; | 1711 element = null; |
| 1712 } | 1712 } |
| 1713 } | 1713 } |
| 1714 if (element == null) { | 1714 if (element == null) { |
| 1715 } else { | 1715 } else { |
| 1716 if (element.library != _resolver.definingLibrary) { | 1716 if (element.library != _resolver.definingLibrary) { |
| 1717 } | 1717 } |
| 1718 recordResolution(simpleIdentifier, element); | 1718 recordResolution(simpleIdentifier, element); |
| 1719 if (node.newKeyword != null) { | 1719 if (node.newKeyword != null) { |
| 1720 if (element is ClassElement) { | 1720 if (element is ClassElement) { |
| 1721 ConstructorElement constructor = ((element as ClassElement)).unnamed
Constructor; | 1721 ConstructorElement constructor = ((element as ClassElement)).unnamed
Constructor; |
| 1722 if (constructor == null) { | 1722 if (constructor == null) { |
| 1723 } else { | 1723 } else { |
| 1724 recordResolution(simpleIdentifier, constructor); | 1724 recordResolution(simpleIdentifier, constructor); |
| 1725 } | 1725 } |
| 1726 } else { | 1726 } else { |
| 1727 } | 1727 } |
| 1728 } | 1728 } |
| 1729 } | 1729 } |
| 1730 } else if (identifier2 is PrefixedIdentifier) { | 1730 } else if (identifier is PrefixedIdentifier) { |
| 1731 PrefixedIdentifier prefixedIdentifier = identifier2 as PrefixedIdentifier; | 1731 PrefixedIdentifier prefixedIdentifier = identifier as PrefixedIdentifier; |
| 1732 SimpleIdentifier prefix2 = prefixedIdentifier.prefix; | 1732 SimpleIdentifier prefix = prefixedIdentifier.prefix; |
| 1733 SimpleIdentifier name = prefixedIdentifier.identifier; | 1733 SimpleIdentifier name = prefixedIdentifier.identifier; |
| 1734 Element element = resolveSimpleIdentifier(prefix2); | 1734 Element element = resolveSimpleIdentifier(prefix); |
| 1735 if (element == null) { | 1735 if (element == null) { |
| 1736 } else { | 1736 } else { |
| 1737 if (element is PrefixElement) { | 1737 if (element is PrefixElement) { |
| 1738 recordResolution(prefix2, element); | 1738 recordResolution(prefix, element); |
| 1739 element = _resolver.nameScope.lookup(identifier2, _resolver.definingLi
brary); | 1739 element = _resolver.nameScope.lookup(identifier, _resolver.definingLib
rary); |
| 1740 recordResolution(name, element); | 1740 recordResolution(name, element); |
| 1741 return null; | 1741 return null; |
| 1742 } | 1742 } |
| 1743 LibraryElement library2 = element.library; | 1743 LibraryElement library = element.library; |
| 1744 if (library2 == null) { | 1744 if (library == null) { |
| 1745 AnalysisEngine.instance.logger.logError("Found element with null libra
ry: ${element.name}"); | 1745 AnalysisEngine.instance.logger.logError("Found element with null libra
ry: ${element.name}"); |
| 1746 } else if (library2 != _resolver.definingLibrary) { | 1746 } else if (library != _resolver.definingLibrary) { |
| 1747 } | 1747 } |
| 1748 recordResolution(name, element); | 1748 recordResolution(name, element); |
| 1749 if (node.newKeyword == null) { | 1749 if (node.newKeyword == null) { |
| 1750 if (element is ClassElement) { | 1750 if (element is ClassElement) { |
| 1751 Element memberElement = lookupGetterOrMethod(((element as ClassEleme
nt)).type, name.name); | 1751 Element memberElement = lookupGetterOrMethod(((element as ClassEleme
nt)).type, name.name); |
| 1752 if (memberElement == null) { | 1752 if (memberElement == null) { |
| 1753 memberElement = ((element as ClassElement)).getNamedConstructor(na
me.name); | 1753 memberElement = ((element as ClassElement)).getNamedConstructor(na
me.name); |
| 1754 if (memberElement == null) { | 1754 if (memberElement == null) { |
| 1755 memberElement = lookUpSetter(prefix2, ((element as ClassElement)
).type, name.name); | 1755 memberElement = lookUpSetter(prefix, ((element as ClassElement))
.type, name.name); |
| 1756 } | 1756 } |
| 1757 } | 1757 } |
| 1758 if (memberElement == null) { | 1758 if (memberElement == null) { |
| 1759 } else { | 1759 } else { |
| 1760 recordResolution(name, memberElement); | 1760 recordResolution(name, memberElement); |
| 1761 } | 1761 } |
| 1762 } else { | 1762 } else { |
| 1763 } | 1763 } |
| 1764 } else { | 1764 } else { |
| 1765 if (element is ClassElement) { | 1765 if (element is ClassElement) { |
| 1766 ConstructorElement constructor = ((element as ClassElement)).getName
dConstructor(name.name); | 1766 ConstructorElement constructor = ((element as ClassElement)).getName
dConstructor(name.name); |
| 1767 if (constructor == null) { | 1767 if (constructor == null) { |
| 1768 } else { | 1768 } else { |
| 1769 recordResolution(name, constructor); | 1769 recordResolution(name, constructor); |
| 1770 } | 1770 } |
| 1771 } else { | 1771 } else { |
| 1772 } | 1772 } |
| 1773 } | 1773 } |
| 1774 } | 1774 } |
| 1775 } | 1775 } |
| 1776 return null; | 1776 return null; |
| 1777 } | 1777 } |
| 1778 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 1778 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 1779 super.visitConstructorDeclaration(node); | 1779 super.visitConstructorDeclaration(node); |
| 1780 ConstructorElement element2 = node.element; | 1780 ConstructorElement element = node.element; |
| 1781 if (element2 is ConstructorElementImpl) { | 1781 if (element is ConstructorElementImpl) { |
| 1782 ConstructorElementImpl constructorElement = element2 as ConstructorElement
Impl; | 1782 ConstructorElementImpl constructorElement = element as ConstructorElementI
mpl; |
| 1783 ConstructorName redirectedNode = node.redirectedConstructor; | 1783 ConstructorName redirectedNode = node.redirectedConstructor; |
| 1784 if (redirectedNode != null) { | 1784 if (redirectedNode != null) { |
| 1785 ConstructorElement redirectedElement = redirectedNode.element; | 1785 ConstructorElement redirectedElement = redirectedNode.element; |
| 1786 constructorElement.redirectedConstructor = redirectedElement; | 1786 constructorElement.redirectedConstructor = redirectedElement; |
| 1787 } | 1787 } |
| 1788 for (ConstructorInitializer initializer in node.initializers) { | 1788 for (ConstructorInitializer initializer in node.initializers) { |
| 1789 if (initializer is RedirectingConstructorInvocation) { | 1789 if (initializer is RedirectingConstructorInvocation) { |
| 1790 ConstructorElement redirectedElement = ((initializer as RedirectingCon
structorInvocation)).element; | 1790 ConstructorElement redirectedElement = ((initializer as RedirectingCon
structorInvocation)).element; |
| 1791 constructorElement.redirectedConstructor = redirectedElement; | 1791 constructorElement.redirectedConstructor = redirectedElement; |
| 1792 } | 1792 } |
| 1793 } | 1793 } |
| 1794 setMetadata(constructorElement, node); | 1794 setMetadata(constructorElement, node); |
| 1795 } | 1795 } |
| 1796 return null; | 1796 return null; |
| 1797 } | 1797 } |
| 1798 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 1798 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 1799 SimpleIdentifier fieldName2 = node.fieldName; | 1799 SimpleIdentifier fieldName = node.fieldName; |
| 1800 ClassElement enclosingClass2 = _resolver.enclosingClass; | 1800 ClassElement enclosingClass = _resolver.enclosingClass; |
| 1801 FieldElement fieldElement = ((enclosingClass2 as ClassElementImpl)).getField
(fieldName2.name); | 1801 FieldElement fieldElement = ((enclosingClass as ClassElementImpl)).getField(
fieldName.name); |
| 1802 recordResolution(fieldName2, fieldElement); | 1802 recordResolution(fieldName, fieldElement); |
| 1803 if (fieldElement == null || fieldElement.isSynthetic()) { | 1803 if (fieldElement == null || fieldElement.isSynthetic()) { |
| 1804 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FI
ELD, node, [fieldName2]); | 1804 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FI
ELD, node, [fieldName]); |
| 1805 } else if (fieldElement.isStatic()) { | 1805 } else if (fieldElement.isStatic()) { |
| 1806 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, n
ode, [fieldName2]); | 1806 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, n
ode, [fieldName]); |
| 1807 } | 1807 } |
| 1808 return null; | 1808 return null; |
| 1809 } | 1809 } |
| 1810 Object visitConstructorName(ConstructorName node) { | 1810 Object visitConstructorName(ConstructorName node) { |
| 1811 Type2 type2 = node.type.type; | 1811 Type2 type = node.type.type; |
| 1812 if (type2 != null && type2.isDynamic()) { | 1812 if (type != null && type.isDynamic()) { |
| 1813 return null; | 1813 return null; |
| 1814 } else if (type2 is! InterfaceType) { | 1814 } else if (type is! InterfaceType) { |
| 1815 ASTNode parent2 = node.parent; | 1815 ASTNode parent = node.parent; |
| 1816 if (parent2 is InstanceCreationExpression) { | 1816 if (parent is InstanceCreationExpression) { |
| 1817 if (((parent2 as InstanceCreationExpression)).isConst()) { | 1817 if (((parent as InstanceCreationExpression)).isConst()) { |
| 1818 } else { | 1818 } else { |
| 1819 } | 1819 } |
| 1820 } else { | 1820 } else { |
| 1821 } | 1821 } |
| 1822 return null; | 1822 return null; |
| 1823 } | 1823 } |
| 1824 ConstructorElement constructor; | 1824 ConstructorElement constructor; |
| 1825 SimpleIdentifier name2 = node.name; | 1825 SimpleIdentifier name = node.name; |
| 1826 InterfaceType interfaceType = type2 as InterfaceType; | 1826 InterfaceType interfaceType = type as InterfaceType; |
| 1827 LibraryElement definingLibrary2 = _resolver.definingLibrary; | 1827 LibraryElement definingLibrary = _resolver.definingLibrary; |
| 1828 if (name2 == null) { | 1828 if (name == null) { |
| 1829 constructor = interfaceType.lookUpConstructor(null, definingLibrary2); | 1829 constructor = interfaceType.lookUpConstructor(null, definingLibrary); |
| 1830 } else { | 1830 } else { |
| 1831 constructor = interfaceType.lookUpConstructor(name2.name, definingLibrary2
); | 1831 constructor = interfaceType.lookUpConstructor(name.name, definingLibrary); |
| 1832 name2.staticElement = constructor; | 1832 name.staticElement = constructor; |
| 1833 name2.element = constructor; | 1833 name.element = constructor; |
| 1834 } | 1834 } |
| 1835 node.staticElement = constructor; | 1835 node.staticElement = constructor; |
| 1836 node.element = constructor; | 1836 node.element = constructor; |
| 1837 return null; | 1837 return null; |
| 1838 } | 1838 } |
| 1839 Object visitContinueStatement(ContinueStatement node) { | 1839 Object visitContinueStatement(ContinueStatement node) { |
| 1840 SimpleIdentifier labelNode = node.label; | 1840 SimpleIdentifier labelNode = node.label; |
| 1841 LabelElementImpl labelElement = lookupLabel(node, labelNode); | 1841 LabelElementImpl labelElement = lookupLabel(node, labelNode); |
| 1842 if (labelElement != null && labelElement.isOnSwitchStatement()) { | 1842 if (labelElement != null && labelElement.isOnSwitchStatement()) { |
| 1843 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod
e, []); | 1843 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod
e, []); |
| 1844 } | 1844 } |
| 1845 return null; | 1845 return null; |
| 1846 } | 1846 } |
| 1847 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 1847 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 1848 setMetadata(node.element, node); | 1848 setMetadata(node.element, node); |
| 1849 return null; | 1849 return null; |
| 1850 } | 1850 } |
| 1851 Object visitExportDirective(ExportDirective node) { | 1851 Object visitExportDirective(ExportDirective node) { |
| 1852 Element element2 = node.element; | 1852 Element element = node.element; |
| 1853 if (element2 is ExportElement) { | 1853 if (element is ExportElement) { |
| 1854 resolveCombinators(((element2 as ExportElement)).exportedLibrary, node.com
binators); | 1854 resolveCombinators(((element as ExportElement)).exportedLibrary, node.comb
inators); |
| 1855 setMetadata(element2, node); | 1855 setMetadata(element, node); |
| 1856 } | 1856 } |
| 1857 return null; | 1857 return null; |
| 1858 } | 1858 } |
| 1859 Object visitFieldFormalParameter(FieldFormalParameter node) { | 1859 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 1860 String fieldName = node.identifier.name; | 1860 String fieldName = node.identifier.name; |
| 1861 ClassElement classElement = _resolver.enclosingClass; | 1861 ClassElement classElement = _resolver.enclosingClass; |
| 1862 if (classElement != null) { | 1862 if (classElement != null) { |
| 1863 FieldElement fieldElement = ((classElement as ClassElementImpl)).getField(
fieldName); | 1863 FieldElement fieldElement = ((classElement as ClassElementImpl)).getField(
fieldName); |
| 1864 if (fieldElement == null) { | 1864 if (fieldElement == null) { |
| 1865 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_E
XISTANT_FIELD, node, [fieldName]); | 1865 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_E
XISTANT_FIELD, node, [fieldName]); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 SimpleIdentifier prefixNode = node.prefix; | 1904 SimpleIdentifier prefixNode = node.prefix; |
| 1905 if (prefixNode != null) { | 1905 if (prefixNode != null) { |
| 1906 String prefixName = prefixNode.name; | 1906 String prefixName = prefixNode.name; |
| 1907 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) { | 1907 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) { |
| 1908 if (prefixElement.displayName == prefixName) { | 1908 if (prefixElement.displayName == prefixName) { |
| 1909 recordResolution(prefixNode, prefixElement); | 1909 recordResolution(prefixNode, prefixElement); |
| 1910 break; | 1910 break; |
| 1911 } | 1911 } |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| 1914 Element element2 = node.element; | 1914 Element element = node.element; |
| 1915 if (element2 is ImportElement) { | 1915 if (element is ImportElement) { |
| 1916 ImportElement importElement = element2 as ImportElement; | 1916 ImportElement importElement = element as ImportElement; |
| 1917 LibraryElement library = importElement.importedLibrary; | 1917 LibraryElement library = importElement.importedLibrary; |
| 1918 if (library != null) { | 1918 if (library != null) { |
| 1919 resolveCombinators(library, node.combinators); | 1919 resolveCombinators(library, node.combinators); |
| 1920 } | 1920 } |
| 1921 setMetadata(element2, node); | 1921 setMetadata(element, node); |
| 1922 } | 1922 } |
| 1923 return null; | 1923 return null; |
| 1924 } | 1924 } |
| 1925 Object visitIndexExpression(IndexExpression node) { | 1925 Object visitIndexExpression(IndexExpression node) { |
| 1926 Expression target = node.realTarget; | 1926 Expression target = node.realTarget; |
| 1927 Type2 staticType = getStaticType(target); | 1927 Type2 staticType = getStaticType(target); |
| 1928 Type2 propagatedType = getPropagatedType(target); | 1928 Type2 propagatedType = getPropagatedType(target); |
| 1929 if (node.inGetterContext()) { | 1929 if (node.inGetterContext()) { |
| 1930 String methodName = sc.TokenType.INDEX.lexeme; | 1930 String methodName = sc.TokenType.INDEX.lexeme; |
| 1931 bool error = lookUpCheckIndexOperator(node, target, methodName, staticType
, propagatedType); | 1931 bool error = lookUpCheckIndexOperator(node, target, methodName, staticType
, propagatedType); |
| 1932 if (error) { | 1932 if (error) { |
| 1933 return null; | 1933 return null; |
| 1934 } | 1934 } |
| 1935 } | 1935 } |
| 1936 if (node.inSetterContext()) { | 1936 if (node.inSetterContext()) { |
| 1937 String methodName = sc.TokenType.INDEX_EQ.lexeme; | 1937 String methodName = sc.TokenType.INDEX_EQ.lexeme; |
| 1938 lookUpCheckIndexOperator(node, target, methodName, staticType, propagatedT
ype); | 1938 lookUpCheckIndexOperator(node, target, methodName, staticType, propagatedT
ype); |
| 1939 } | 1939 } |
| 1940 return null; | 1940 return null; |
| 1941 } | 1941 } |
| 1942 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 1942 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 1943 ConstructorElement invokedConstructor = node.constructorName.element; | 1943 ConstructorElement invokedConstructor = node.constructorName.element; |
| 1944 node.staticElement = invokedConstructor; | 1944 node.staticElement = invokedConstructor; |
| 1945 node.element = invokedConstructor; | 1945 node.element = invokedConstructor; |
| 1946 ArgumentList argumentList2 = node.argumentList; | 1946 ArgumentList argumentList = node.argumentList; |
| 1947 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons
t(), argumentList2, invokedConstructor); | 1947 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons
t(), argumentList, invokedConstructor); |
| 1948 if (parameters != null) { | 1948 if (parameters != null) { |
| 1949 argumentList2.correspondingStaticParameters = parameters; | 1949 argumentList.correspondingStaticParameters = parameters; |
| 1950 } | 1950 } |
| 1951 return null; | 1951 return null; |
| 1952 } | 1952 } |
| 1953 Object visitLibraryDirective(LibraryDirective node) { | 1953 Object visitLibraryDirective(LibraryDirective node) { |
| 1954 setMetadata(node.element, node); | 1954 setMetadata(node.element, node); |
| 1955 return null; | 1955 return null; |
| 1956 } | 1956 } |
| 1957 Object visitMethodDeclaration(MethodDeclaration node) { | 1957 Object visitMethodDeclaration(MethodDeclaration node) { |
| 1958 setMetadata(node.element, node); | 1958 setMetadata(node.element, node); |
| 1959 return null; | 1959 return null; |
| 1960 } | 1960 } |
| 1961 Object visitMethodInvocation(MethodInvocation node) { | 1961 Object visitMethodInvocation(MethodInvocation node) { |
| 1962 SimpleIdentifier methodName2 = node.methodName; | 1962 SimpleIdentifier methodName = node.methodName; |
| 1963 Expression target = node.realTarget; | 1963 Expression target = node.realTarget; |
| 1964 Element staticElement; | 1964 Element staticElement; |
| 1965 Element propagatedElement; | 1965 Element propagatedElement; |
| 1966 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { | 1966 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { |
| 1967 return null; | 1967 return null; |
| 1968 } | 1968 } |
| 1969 if (target == null) { | 1969 if (target == null) { |
| 1970 staticElement = resolveInvokedElement2(methodName2); | 1970 staticElement = resolveInvokedElement2(methodName); |
| 1971 propagatedElement = null; | 1971 propagatedElement = null; |
| 1972 } else { | 1972 } else { |
| 1973 Type2 targetType = getStaticType(target); | 1973 Type2 targetType = getStaticType(target); |
| 1974 staticElement = resolveInvokedElement(target, targetType, methodName2); | 1974 staticElement = resolveInvokedElement(target, targetType, methodName); |
| 1975 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName2); | 1975 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); |
| 1976 } | 1976 } |
| 1977 staticElement = convertSetterToGetter(staticElement); | 1977 staticElement = convertSetterToGetter(staticElement); |
| 1978 propagatedElement = convertSetterToGetter(propagatedElement); | 1978 propagatedElement = convertSetterToGetter(propagatedElement); |
| 1979 recordResolution2(methodName2, staticElement, propagatedElement); | 1979 recordResolution2(methodName, staticElement, propagatedElement); |
| 1980 ArgumentList argumentList2 = node.argumentList; | 1980 ArgumentList argumentList = node.argumentList; |
| 1981 if (staticElement != null) { | 1981 if (staticElement != null) { |
| 1982 List<ParameterElement> parameters = computePropagatedParameters(argumentLi
st2, staticElement); | 1982 List<ParameterElement> parameters = computePropagatedParameters(argumentLi
st, staticElement); |
| 1983 if (parameters != null) { | 1983 if (parameters != null) { |
| 1984 argumentList2.correspondingStaticParameters = parameters; | 1984 argumentList.correspondingStaticParameters = parameters; |
| 1985 } | 1985 } |
| 1986 } | 1986 } |
| 1987 if (propagatedElement != null) { | 1987 if (propagatedElement != null) { |
| 1988 List<ParameterElement> parameters = computePropagatedParameters(argumentLi
st2, propagatedElement); | 1988 List<ParameterElement> parameters = computePropagatedParameters(argumentLi
st, propagatedElement); |
| 1989 if (parameters != null) { | 1989 if (parameters != null) { |
| 1990 argumentList2.correspondingParameters = parameters; | 1990 argumentList.correspondingParameters = parameters; |
| 1991 } | 1991 } |
| 1992 } | 1992 } |
| 1993 ErrorCode errorCode; | 1993 ErrorCode errorCode; |
| 1994 if (staticElement == null) { | 1994 if (staticElement == null) { |
| 1995 if (propagatedElement == null) { | 1995 if (propagatedElement == null) { |
| 1996 errorCode = checkForInvocationError(target, staticElement); | 1996 errorCode = checkForInvocationError(target, staticElement); |
| 1997 } else { | 1997 } else { |
| 1998 errorCode = checkForInvocationError(target, propagatedElement); | 1998 errorCode = checkForInvocationError(target, propagatedElement); |
| 1999 } | 1999 } |
| 2000 } else { | 2000 } else { |
| 2001 errorCode = checkForInvocationError(target, staticElement); | 2001 errorCode = checkForInvocationError(target, staticElement); |
| 2002 if (propagatedElement != null) { | 2002 if (propagatedElement != null) { |
| 2003 ErrorCode propagatedError = checkForInvocationError(target, propagatedEl
ement); | 2003 ErrorCode propagatedError = checkForInvocationError(target, propagatedEl
ement); |
| 2004 errorCode = select(errorCode, propagatedError); | 2004 errorCode = select(errorCode, propagatedError); |
| 2005 } | 2005 } |
| 2006 } | 2006 } |
| 2007 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION))
{ | 2007 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION))
{ |
| 2008 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, me
thodName2, [methodName2.name]); | 2008 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, me
thodName, [methodName.name]); |
| 2009 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) { | 2009 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) { |
| 2010 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_FUNCTION, methodName
2, [methodName2.name]); | 2010 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_FUNCTION, methodName
, [methodName.name]); |
| 2011 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { | 2011 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { |
| 2012 String targetTypeName; | 2012 String targetTypeName; |
| 2013 if (target == null) { | 2013 if (target == null) { |
| 2014 ClassElement enclosingClass2 = _resolver.enclosingClass; | 2014 ClassElement enclosingClass = _resolver.enclosingClass; |
| 2015 targetTypeName = enclosingClass2.displayName; | 2015 targetTypeName = enclosingClass.displayName; |
| 2016 } else { | 2016 } else { |
| 2017 Type2 targetType = getPropagatedType(target); | 2017 Type2 targetType = getPropagatedType(target); |
| 2018 if (targetType == null) { | 2018 if (targetType == null) { |
| 2019 targetType = getStaticType(target); | 2019 targetType = getStaticType(target); |
| 2020 } | 2020 } |
| 2021 targetTypeName = targetType == null ? null : targetType.displayName; | 2021 targetTypeName = targetType == null ? null : targetType.displayName; |
| 2022 } | 2022 } |
| 2023 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_METHOD, methodName2,
[methodName2.name, targetTypeName]); | 2023 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_METHOD, methodName,
[methodName.name, targetTypeName]); |
| 2024 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { | 2024 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { |
| 2025 Type2 targetType = getPropagatedType(target); | 2025 Type2 targetType = getPropagatedType(target); |
| 2026 if (targetType == null) { | 2026 if (targetType == null) { |
| 2027 targetType = getStaticType(target); | 2027 targetType = getStaticType(target); |
| 2028 } | 2028 } |
| 2029 String targetTypeName = targetType == null ? null : targetType.name; | 2029 String targetTypeName = targetType == null ? null : targetType.name; |
| 2030 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, method
Name2, [methodName2.name, targetTypeName]); | 2030 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, method
Name, [methodName.name, targetTypeName]); |
| 2031 } | 2031 } |
| 2032 return null; | 2032 return null; |
| 2033 } | 2033 } |
| 2034 Object visitPartDirective(PartDirective node) { | 2034 Object visitPartDirective(PartDirective node) { |
| 2035 setMetadata(node.element, node); | 2035 setMetadata(node.element, node); |
| 2036 return null; | 2036 return null; |
| 2037 } | 2037 } |
| 2038 Object visitPartOfDirective(PartOfDirective node) { | 2038 Object visitPartOfDirective(PartOfDirective node) { |
| 2039 setMetadata(node.element, node); | 2039 setMetadata(node.element, node); |
| 2040 return null; | 2040 return null; |
| 2041 } | 2041 } |
| 2042 Object visitPostfixExpression(PostfixExpression node) { | 2042 Object visitPostfixExpression(PostfixExpression node) { |
| 2043 Expression operand2 = node.operand; | 2043 Expression operand = node.operand; |
| 2044 String methodName = getPostfixOperator(node); | 2044 String methodName = getPostfixOperator(node); |
| 2045 Type2 staticType = getStaticType(operand2); | 2045 Type2 staticType = getStaticType(operand); |
| 2046 MethodElement staticMethod = lookUpMethod(operand2, staticType, methodName); | 2046 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName); |
| 2047 node.staticElement = staticMethod; | 2047 node.staticElement = staticMethod; |
| 2048 Type2 propagatedType = getPropagatedType(operand2); | 2048 Type2 propagatedType = getPropagatedType(operand); |
| 2049 MethodElement propagatedMethod = lookUpMethod(operand2, propagatedType, meth
odName); | 2049 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, metho
dName); |
| 2050 node.element = select3(staticMethod, propagatedMethod); | 2050 node.element = select3(staticMethod, propagatedMethod); |
| 2051 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { | 2051 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { |
| 2052 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, node.oper
ator, [methodName, staticType.displayName]); | 2052 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, node.oper
ator, [methodName, staticType.displayName]); |
| 2053 } | 2053 } |
| 2054 return null; | 2054 return null; |
| 2055 } | 2055 } |
| 2056 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 2056 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 2057 SimpleIdentifier prefix2 = node.prefix; | 2057 SimpleIdentifier prefix = node.prefix; |
| 2058 SimpleIdentifier identifier2 = node.identifier; | 2058 SimpleIdentifier identifier = node.identifier; |
| 2059 Element prefixElement = prefix2.element; | 2059 Element prefixElement = prefix.element; |
| 2060 if (prefixElement is PrefixElement) { | 2060 if (prefixElement is PrefixElement) { |
| 2061 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibra
ry); | 2061 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibra
ry); |
| 2062 if (element == null) { | 2062 if (element == null) { |
| 2063 return null; | 2063 return null; |
| 2064 } | 2064 } |
| 2065 if (element is PropertyAccessorElement && identifier2.inSetterContext()) { | 2065 if (element is PropertyAccessorElement && identifier.inSetterContext()) { |
| 2066 PropertyInducingElement variable2 = ((element as PropertyAccessorElement
)).variable; | 2066 PropertyInducingElement variable = ((element as PropertyAccessorElement)
).variable; |
| 2067 if (variable2 != null) { | 2067 if (variable != null) { |
| 2068 PropertyAccessorElement setter2 = variable2.setter; | 2068 PropertyAccessorElement setter = variable.setter; |
| 2069 if (setter2 != null) { | 2069 if (setter != null) { |
| 2070 element = setter2; | 2070 element = setter; |
| 2071 } | 2071 } |
| 2072 } | 2072 } |
| 2073 } | 2073 } |
| 2074 recordResolution(identifier2, element); | 2074 recordResolution(identifier, element); |
| 2075 return null; | 2075 return null; |
| 2076 } | 2076 } |
| 2077 resolvePropertyAccess(prefix2, identifier2); | 2077 resolvePropertyAccess(prefix, identifier); |
| 2078 return null; | 2078 return null; |
| 2079 } | 2079 } |
| 2080 Object visitPrefixExpression(PrefixExpression node) { | 2080 Object visitPrefixExpression(PrefixExpression node) { |
| 2081 sc.Token operator2 = node.operator; | 2081 sc.Token operator = node.operator; |
| 2082 sc.TokenType operatorType = operator2.type; | 2082 sc.TokenType operatorType = operator.type; |
| 2083 if (operatorType.isUserDefinableOperator() || identical(operatorType, sc.Tok
enType.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { | 2083 if (operatorType.isUserDefinableOperator() || identical(operatorType, sc.Tok
enType.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { |
| 2084 Expression operand2 = node.operand; | 2084 Expression operand = node.operand; |
| 2085 String methodName = getPrefixOperator(node); | 2085 String methodName = getPrefixOperator(node); |
| 2086 Type2 staticType = getStaticType(operand2); | 2086 Type2 staticType = getStaticType(operand); |
| 2087 MethodElement staticMethod = lookUpMethod(operand2, staticType, methodName
); | 2087 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName)
; |
| 2088 node.staticElement = staticMethod; | 2088 node.staticElement = staticMethod; |
| 2089 Type2 propagatedType = getPropagatedType(operand2); | 2089 Type2 propagatedType = getPropagatedType(operand); |
| 2090 MethodElement propagatedMethod = lookUpMethod(operand2, propagatedType, me
thodName); | 2090 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, met
hodName); |
| 2091 node.element = select3(staticMethod, propagatedMethod); | 2091 node.element = select3(staticMethod, propagatedMethod); |
| 2092 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM
ethod))) { | 2092 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM
ethod))) { |
| 2093 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operato
r2, [methodName, staticType.displayName]); | 2093 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operato
r, [methodName, staticType.displayName]); |
| 2094 } | 2094 } |
| 2095 } | 2095 } |
| 2096 return null; | 2096 return null; |
| 2097 } | 2097 } |
| 2098 Object visitPropertyAccess(PropertyAccess node) { | 2098 Object visitPropertyAccess(PropertyAccess node) { |
| 2099 Expression target = node.realTarget; | 2099 Expression target = node.realTarget; |
| 2100 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { | 2100 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { |
| 2101 return null; | 2101 return null; |
| 2102 } | 2102 } |
| 2103 SimpleIdentifier propertyName2 = node.propertyName; | 2103 SimpleIdentifier propertyName = node.propertyName; |
| 2104 resolvePropertyAccess(target, propertyName2); | 2104 resolvePropertyAccess(target, propertyName); |
| 2105 return null; | 2105 return null; |
| 2106 } | 2106 } |
| 2107 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 2107 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 2108 ClassElement enclosingClass2 = _resolver.enclosingClass; | 2108 ClassElement enclosingClass = _resolver.enclosingClass; |
| 2109 if (enclosingClass2 == null) { | 2109 if (enclosingClass == null) { |
| 2110 return null; | 2110 return null; |
| 2111 } | 2111 } |
| 2112 SimpleIdentifier name = node.constructorName; | 2112 SimpleIdentifier name = node.constructorName; |
| 2113 ConstructorElement element; | 2113 ConstructorElement element; |
| 2114 if (name == null) { | 2114 if (name == null) { |
| 2115 element = enclosingClass2.unnamedConstructor; | 2115 element = enclosingClass.unnamedConstructor; |
| 2116 } else { | 2116 } else { |
| 2117 element = enclosingClass2.getNamedConstructor(name.name); | 2117 element = enclosingClass.getNamedConstructor(name.name); |
| 2118 } | 2118 } |
| 2119 if (element == null) { | 2119 if (element == null) { |
| 2120 return null; | 2120 return null; |
| 2121 } | 2121 } |
| 2122 if (name != null) { | 2122 if (name != null) { |
| 2123 recordResolution(name, element); | 2123 recordResolution(name, element); |
| 2124 } | 2124 } |
| 2125 node.staticElement = element; | 2125 node.staticElement = element; |
| 2126 node.element = element; | 2126 node.element = element; |
| 2127 ArgumentList argumentList2 = node.argumentList; | 2127 ArgumentList argumentList = node.argumentList; |
| 2128 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu
mentList2, element); | 2128 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu
mentList, element); |
| 2129 if (parameters != null) { | 2129 if (parameters != null) { |
| 2130 argumentList2.correspondingStaticParameters = parameters; | 2130 argumentList.correspondingStaticParameters = parameters; |
| 2131 } | 2131 } |
| 2132 return null; | 2132 return null; |
| 2133 } | 2133 } |
| 2134 Object visitSimpleIdentifier(SimpleIdentifier node) { | 2134 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 2135 if (node.element != null) { | 2135 if (node.element != null) { |
| 2136 return null; | 2136 return null; |
| 2137 } | 2137 } |
| 2138 Element element = resolveSimpleIdentifier(node); | 2138 Element element = resolveSimpleIdentifier(node); |
| 2139 if (isFactoryConstructorReturnType(node) && element != _resolver.enclosingCl
ass) { | 2139 if (isFactoryConstructorReturnType(node) && element != _resolver.enclosingCl
ass) { |
| 2140 _resolver.reportError(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLAS
S, node, []); | 2140 _resolver.reportError(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLAS
S, node, []); |
| 2141 } else if (element == null) { | 2141 } else if (element == null) { |
| 2142 if (isConstructorReturnType(node)) { | 2142 if (isConstructorReturnType(node)) { |
| 2143 _resolver.reportError(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, nod
e, []); | 2143 _resolver.reportError(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, nod
e, []); |
| 2144 } else if (!classDeclaresNoSuchMethod(_resolver.enclosingClass)) { | 2144 } else if (!classDeclaresNoSuchMethod(_resolver.enclosingClass)) { |
| 2145 _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, [nod
e.name]); | 2145 _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, [nod
e.name]); |
| 2146 } | 2146 } |
| 2147 } | 2147 } |
| 2148 recordResolution(node, element); | 2148 recordResolution(node, element); |
| 2149 return null; | 2149 return null; |
| 2150 } | 2150 } |
| 2151 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 2151 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 2152 ClassElement enclosingClass2 = _resolver.enclosingClass; | 2152 ClassElement enclosingClass = _resolver.enclosingClass; |
| 2153 if (enclosingClass2 == null) { | 2153 if (enclosingClass == null) { |
| 2154 return null; | 2154 return null; |
| 2155 } | 2155 } |
| 2156 ClassElement superclass = getSuperclass(enclosingClass2); | 2156 ClassElement superclass = getSuperclass(enclosingClass); |
| 2157 if (superclass == null) { | 2157 if (superclass == null) { |
| 2158 return null; | 2158 return null; |
| 2159 } | 2159 } |
| 2160 SimpleIdentifier name = node.constructorName; | 2160 SimpleIdentifier name = node.constructorName; |
| 2161 ConstructorElement element; | 2161 ConstructorElement element; |
| 2162 if (name == null) { | 2162 if (name == null) { |
| 2163 element = superclass.unnamedConstructor; | 2163 element = superclass.unnamedConstructor; |
| 2164 } else { | 2164 } else { |
| 2165 element = superclass.getNamedConstructor(name.name); | 2165 element = superclass.getNamedConstructor(name.name); |
| 2166 } | 2166 } |
| 2167 if (element == null) { | 2167 if (element == null) { |
| 2168 if (name != null) { | 2168 if (name != null) { |
| 2169 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER, node, [superclass.name, name]); | 2169 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER, node, [superclass.name, name]); |
| 2170 } else { | 2170 } else { |
| 2171 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER_DEFAULT, node, [superclass.name]); | 2171 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER_DEFAULT, node, [superclass.name]); |
| 2172 } | 2172 } |
| 2173 return null; | 2173 return null; |
| 2174 } else { | 2174 } else { |
| 2175 if (element.isFactory()) { | 2175 if (element.isFactory()) { |
| 2176 _resolver.reportError(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, n
ode, [element]); | 2176 _resolver.reportError(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, n
ode, [element]); |
| 2177 } | 2177 } |
| 2178 } | 2178 } |
| 2179 if (name != null) { | 2179 if (name != null) { |
| 2180 recordResolution(name, element); | 2180 recordResolution(name, element); |
| 2181 } | 2181 } |
| 2182 node.staticElement = element; | 2182 node.staticElement = element; |
| 2183 node.element = element; | 2183 node.element = element; |
| 2184 ArgumentList argumentList2 = node.argumentList; | 2184 ArgumentList argumentList = node.argumentList; |
| 2185 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu
mentList2, element); | 2185 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu
mentList, element); |
| 2186 if (parameters != null) { | 2186 if (parameters != null) { |
| 2187 argumentList2.correspondingStaticParameters = parameters; | 2187 argumentList.correspondingStaticParameters = parameters; |
| 2188 } | 2188 } |
| 2189 return null; | 2189 return null; |
| 2190 } | 2190 } |
| 2191 Object visitSuperExpression(SuperExpression node) { | 2191 Object visitSuperExpression(SuperExpression node) { |
| 2192 if (!isSuperInValidContext(node)) { | 2192 if (!isSuperInValidContext(node)) { |
| 2193 _resolver.reportError(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT, node,
[]); | 2193 _resolver.reportError(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT, node,
[]); |
| 2194 } | 2194 } |
| 2195 return super.visitSuperExpression(node); | 2195 return super.visitSuperExpression(node); |
| 2196 } | 2196 } |
| 2197 Object visitTypeParameter(TypeParameter node) { | 2197 Object visitTypeParameter(TypeParameter node) { |
| 2198 TypeName bound2 = node.bound; | 2198 TypeName bound = node.bound; |
| 2199 if (bound2 != null) { | 2199 if (bound != null) { |
| 2200 TypeVariableElementImpl variable = node.name.element as TypeVariableElemen
tImpl; | 2200 TypeVariableElementImpl variable = node.name.element as TypeVariableElemen
tImpl; |
| 2201 if (variable != null) { | 2201 if (variable != null) { |
| 2202 variable.bound = bound2.type; | 2202 variable.bound = bound.type; |
| 2203 } | 2203 } |
| 2204 } | 2204 } |
| 2205 setMetadata(node.element, node); | 2205 setMetadata(node.element, node); |
| 2206 return null; | 2206 return null; |
| 2207 } | 2207 } |
| 2208 Object visitVariableDeclaration(VariableDeclaration node) { | 2208 Object visitVariableDeclaration(VariableDeclaration node) { |
| 2209 setMetadata(node.element, node); | 2209 setMetadata(node.element, node); |
| 2210 return null; | 2210 return null; |
| 2211 } | 2211 } |
| 2212 | 2212 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2229 * Given that we have found code to invoke the given element, return the error
code that should be | 2229 * Given that we have found code to invoke the given element, return the error
code that should be |
| 2230 * reported, or {@code null} if no error should be reported. | 2230 * reported, or {@code null} if no error should be reported. |
| 2231 * @param target the target of the invocation, or {@code null} if there was no
target | 2231 * @param target the target of the invocation, or {@code null} if there was no
target |
| 2232 * @param element the element to be invoked | 2232 * @param element the element to be invoked |
| 2233 * @return the error code that should be reported | 2233 * @return the error code that should be reported |
| 2234 */ | 2234 */ |
| 2235 ErrorCode checkForInvocationError(Expression target, Element element2) { | 2235 ErrorCode checkForInvocationError(Expression target, Element element2) { |
| 2236 if (element2 is PropertyAccessorElement) { | 2236 if (element2 is PropertyAccessorElement) { |
| 2237 FunctionType getterType = ((element2 as PropertyAccessorElement)).type; | 2237 FunctionType getterType = ((element2 as PropertyAccessorElement)).type; |
| 2238 if (getterType != null) { | 2238 if (getterType != null) { |
| 2239 Type2 returnType2 = getterType.returnType; | 2239 Type2 returnType = getterType.returnType; |
| 2240 if (!isExecutableType(returnType2)) { | 2240 if (!isExecutableType(returnType)) { |
| 2241 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 2241 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
| 2242 } | 2242 } |
| 2243 } | 2243 } |
| 2244 } else if (element2 is ExecutableElement) { | 2244 } else if (element2 is ExecutableElement) { |
| 2245 return null; | 2245 return null; |
| 2246 } else if (element2 == null && target is SuperExpression) { | 2246 } else if (element2 == null && target is SuperExpression) { |
| 2247 return StaticTypeWarningCode.UNDEFINED_SUPER_METHOD; | 2247 return StaticTypeWarningCode.UNDEFINED_SUPER_METHOD; |
| 2248 } else { | 2248 } else { |
| 2249 if (element2 is PropertyInducingElement) { | 2249 if (element2 is PropertyInducingElement) { |
| 2250 PropertyAccessorElement getter2 = ((element2 as PropertyInducingElement)
).getter; | 2250 PropertyAccessorElement getter = ((element2 as PropertyInducingElement))
.getter; |
| 2251 FunctionType getterType = getter2.type; | 2251 FunctionType getterType = getter.type; |
| 2252 if (getterType != null) { | 2252 if (getterType != null) { |
| 2253 Type2 returnType3 = getterType.returnType; | 2253 Type2 returnType = getterType.returnType; |
| 2254 if (!isExecutableType(returnType3)) { | 2254 if (!isExecutableType(returnType)) { |
| 2255 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 2255 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
| 2256 } | 2256 } |
| 2257 } | 2257 } |
| 2258 } else if (element2 is VariableElement) { | 2258 } else if (element2 is VariableElement) { |
| 2259 Type2 variableType = _resolver.overrideManager.getType(element2); | 2259 Type2 variableType = _resolver.overrideManager.getType(element2); |
| 2260 if (variableType == null) { | 2260 if (variableType == null) { |
| 2261 variableType = ((element2 as VariableElement)).type; | 2261 variableType = ((element2 as VariableElement)).type; |
| 2262 } | 2262 } |
| 2263 if (!isExecutableType(variableType)) { | 2263 if (!isExecutableType(variableType)) { |
| 2264 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 2264 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
| 2265 } | 2265 } |
| 2266 } else { | 2266 } else { |
| 2267 if (target == null) { | 2267 if (target == null) { |
| 2268 ClassElement enclosingClass2 = _resolver.enclosingClass; | 2268 ClassElement enclosingClass = _resolver.enclosingClass; |
| 2269 if (enclosingClass2 == null) { | 2269 if (enclosingClass == null) { |
| 2270 return StaticTypeWarningCode.UNDEFINED_FUNCTION; | 2270 return StaticTypeWarningCode.UNDEFINED_FUNCTION; |
| 2271 } else if (element2 == null) { | 2271 } else if (element2 == null) { |
| 2272 if (!classDeclaresNoSuchMethod(enclosingClass2)) { | 2272 if (!classDeclaresNoSuchMethod(enclosingClass)) { |
| 2273 return StaticTypeWarningCode.UNDEFINED_METHOD; | 2273 return StaticTypeWarningCode.UNDEFINED_METHOD; |
| 2274 } | 2274 } |
| 2275 } else { | 2275 } else { |
| 2276 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 2276 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
| 2277 } | 2277 } |
| 2278 } else { | 2278 } else { |
| 2279 Type2 targetType = getStaticType(target); | 2279 Type2 targetType = getStaticType(target); |
| 2280 if (targetType == null) { | 2280 if (targetType == null) { |
| 2281 return StaticTypeWarningCode.UNDEFINED_FUNCTION; | 2281 return StaticTypeWarningCode.UNDEFINED_FUNCTION; |
| 2282 } else if (!targetType.isDynamic() && !classDeclaresNoSuchMethod2(targ
etType.element)) { | 2282 } else if (!targetType.isDynamic() && !classDeclaresNoSuchMethod2(targ
etType.element)) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2338 Element functionElement = ((getterReturnType as FunctionType)).element
; | 2338 Element functionElement = ((getterReturnType as FunctionType)).element
; |
| 2339 if (functionElement is ExecutableElement) { | 2339 if (functionElement is ExecutableElement) { |
| 2340 return resolveArgumentsToParameters(false, argumentList, (functionEl
ement as ExecutableElement)); | 2340 return resolveArgumentsToParameters(false, argumentList, (functionEl
ement as ExecutableElement)); |
| 2341 } | 2341 } |
| 2342 } | 2342 } |
| 2343 } | 2343 } |
| 2344 } else if (element2 is ExecutableElement) { | 2344 } else if (element2 is ExecutableElement) { |
| 2345 return resolveArgumentsToParameters(false, argumentList, (element2 as Exec
utableElement)); | 2345 return resolveArgumentsToParameters(false, argumentList, (element2 as Exec
utableElement)); |
| 2346 } else if (element2 is VariableElement) { | 2346 } else if (element2 is VariableElement) { |
| 2347 VariableElement variable = element2 as VariableElement; | 2347 VariableElement variable = element2 as VariableElement; |
| 2348 Type2 type2 = variable.type; | 2348 Type2 type = variable.type; |
| 2349 if (type2 is FunctionType) { | 2349 if (type is FunctionType) { |
| 2350 FunctionType functionType = type2 as FunctionType; | 2350 FunctionType functionType = type as FunctionType; |
| 2351 List<ParameterElement> parameters2 = functionType.parameters; | 2351 List<ParameterElement> parameters = functionType.parameters; |
| 2352 return resolveArgumentsToParameters2(false, argumentList, parameters2); | 2352 return resolveArgumentsToParameters2(false, argumentList, parameters); |
| 2353 } else if (type2 is InterfaceType) { | 2353 } else if (type is InterfaceType) { |
| 2354 MethodElement callMethod = ((type2 as InterfaceType)).lookUpMethod(CALL_
METHOD_NAME, _resolver.definingLibrary); | 2354 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(CALL_M
ETHOD_NAME, _resolver.definingLibrary); |
| 2355 if (callMethod != null) { | 2355 if (callMethod != null) { |
| 2356 List<ParameterElement> parameters3 = callMethod.parameters; | 2356 List<ParameterElement> parameters = callMethod.parameters; |
| 2357 return resolveArgumentsToParameters2(false, argumentList, parameters3)
; | 2357 return resolveArgumentsToParameters2(false, argumentList, parameters); |
| 2358 } | 2358 } |
| 2359 } | 2359 } |
| 2360 } | 2360 } |
| 2361 return null; | 2361 return null; |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 /** | 2364 /** |
| 2365 * If the given element is a setter, return the getter associated with it. Oth
erwise, return the | 2365 * If the given element is a setter, return the getter associated with it. Oth
erwise, return the |
| 2366 * element unchanged. | 2366 * element unchanged. |
| 2367 * @param element the element to be normalized | 2367 * @param element the element to be normalized |
| 2368 * @return a non-setter element derived from the given element | 2368 * @return a non-setter element derived from the given element |
| 2369 */ | 2369 */ |
| 2370 Element convertSetterToGetter(Element element) { | 2370 Element convertSetterToGetter(Element element) { |
| 2371 if (element is PropertyAccessorElement) { | 2371 if (element is PropertyAccessorElement) { |
| 2372 return ((element as PropertyAccessorElement)).variable.getter; | 2372 return ((element as PropertyAccessorElement)).variable.getter; |
| 2373 } | 2373 } |
| 2374 return element; | 2374 return element; |
| 2375 } | 2375 } |
| 2376 | 2376 |
| 2377 /** | 2377 /** |
| 2378 * Look for any declarations of the given identifier that are imported using a
prefix. Return the | 2378 * Look for any declarations of the given identifier that are imported using a
prefix. Return the |
| 2379 * element that was found, or {@code null} if the name is not imported using a
prefix. | 2379 * element that was found, or {@code null} if the name is not imported using a
prefix. |
| 2380 * @param identifier the identifier that might have been imported using a pref
ix | 2380 * @param identifier the identifier that might have been imported using a pref
ix |
| 2381 * @return the element that was found | 2381 * @return the element that was found |
| 2382 */ | 2382 */ |
| 2383 Element findImportWithoutPrefix(SimpleIdentifier identifier) { | 2383 Element findImportWithoutPrefix(SimpleIdentifier identifier) { |
| 2384 Element element = null; | 2384 Element element = null; |
| 2385 Scope nameScope2 = _resolver.nameScope; | 2385 Scope nameScope = _resolver.nameScope; |
| 2386 LibraryElement definingLibrary2 = _resolver.definingLibrary; | 2386 LibraryElement definingLibrary = _resolver.definingLibrary; |
| 2387 for (ImportElement importElement in definingLibrary2.imports) { | 2387 for (ImportElement importElement in definingLibrary.imports) { |
| 2388 PrefixElement prefixElement = importElement.prefix; | 2388 PrefixElement prefixElement = importElement.prefix; |
| 2389 if (prefixElement != null) { | 2389 if (prefixElement != null) { |
| 2390 Identifier prefixedIdentifier = new ElementResolver_SyntheticIdentifier(
"${prefixElement.name}.${identifier.name}"); | 2390 Identifier prefixedIdentifier = new ElementResolver_SyntheticIdentifier(
"${prefixElement.name}.${identifier.name}"); |
| 2391 Element importedElement = nameScope2.lookup(prefixedIdentifier, defining
Library2); | 2391 Element importedElement = nameScope.lookup(prefixedIdentifier, definingL
ibrary); |
| 2392 if (importedElement != null) { | 2392 if (importedElement != null) { |
| 2393 if (element == null) { | 2393 if (element == null) { |
| 2394 element = importedElement; | 2394 element = importedElement; |
| 2395 } else { | 2395 } else { |
| 2396 element = new MultiplyDefinedElementImpl(definingLibrary2.context, e
lement, importedElement); | 2396 element = new MultiplyDefinedElementImpl(definingLibrary.context, el
ement, importedElement); |
| 2397 } | 2397 } |
| 2398 } | 2398 } |
| 2399 } | 2399 } |
| 2400 } | 2400 } |
| 2401 return element; | 2401 return element; |
| 2402 } | 2402 } |
| 2403 | 2403 |
| 2404 /** | 2404 /** |
| 2405 * Return the name of the method invoked by the given postfix expression. | 2405 * Return the name of the method invoked by the given postfix expression. |
| 2406 * @param node the postfix expression being invoked | 2406 * @param node the postfix expression being invoked |
| 2407 * @return the name of the method invoked by the expression | 2407 * @return the name of the method invoked by the expression |
| 2408 */ | 2408 */ |
| 2409 String getPostfixOperator(PostfixExpression node) => (identical(node.operator.
type, sc.TokenType.PLUS_PLUS)) ? sc.TokenType.PLUS.lexeme : sc.TokenType.MINUS.l
exeme; | 2409 String getPostfixOperator(PostfixExpression node) => (identical(node.operator.
type, sc.TokenType.PLUS_PLUS)) ? sc.TokenType.PLUS.lexeme : sc.TokenType.MINUS.l
exeme; |
| 2410 | 2410 |
| 2411 /** | 2411 /** |
| 2412 * Return the name of the method invoked by the given postfix expression. | 2412 * Return the name of the method invoked by the given postfix expression. |
| 2413 * @param node the postfix expression being invoked | 2413 * @param node the postfix expression being invoked |
| 2414 * @return the name of the method invoked by the expression | 2414 * @return the name of the method invoked by the expression |
| 2415 */ | 2415 */ |
| 2416 String getPrefixOperator(PrefixExpression node) { | 2416 String getPrefixOperator(PrefixExpression node) { |
| 2417 sc.Token operator2 = node.operator; | 2417 sc.Token operator = node.operator; |
| 2418 sc.TokenType operatorType = operator2.type; | 2418 sc.TokenType operatorType = operator.type; |
| 2419 if (identical(operatorType, sc.TokenType.PLUS_PLUS)) { | 2419 if (identical(operatorType, sc.TokenType.PLUS_PLUS)) { |
| 2420 return sc.TokenType.PLUS.lexeme; | 2420 return sc.TokenType.PLUS.lexeme; |
| 2421 } else if (identical(operatorType, sc.TokenType.MINUS_MINUS)) { | 2421 } else if (identical(operatorType, sc.TokenType.MINUS_MINUS)) { |
| 2422 return sc.TokenType.MINUS.lexeme; | 2422 return sc.TokenType.MINUS.lexeme; |
| 2423 } else if (identical(operatorType, sc.TokenType.MINUS)) { | 2423 } else if (identical(operatorType, sc.TokenType.MINUS)) { |
| 2424 return "unary-"; | 2424 return "unary-"; |
| 2425 } else { | 2425 } else { |
| 2426 return operator2.lexeme; | 2426 return operator.lexeme; |
| 2427 } | 2427 } |
| 2428 } | 2428 } |
| 2429 | 2429 |
| 2430 /** | 2430 /** |
| 2431 * Return the propagated type of the given expression that is to be used for t
ype analysis. | 2431 * Return the propagated type of the given expression that is to be used for t
ype analysis. |
| 2432 * @param expression the expression whose type is to be returned | 2432 * @param expression the expression whose type is to be returned |
| 2433 * @return the type of the given expression | 2433 * @return the type of the given expression |
| 2434 */ | 2434 */ |
| 2435 Type2 getPropagatedType(Expression expression) { | 2435 Type2 getPropagatedType(Expression expression) { |
| 2436 Type2 propagatedType2 = resolveTypeVariable(expression.propagatedType); | 2436 Type2 propagatedType = resolveTypeVariable(expression.propagatedType); |
| 2437 if (propagatedType2 is FunctionType) { | 2437 if (propagatedType is FunctionType) { |
| 2438 propagatedType2 = _resolver.typeProvider.functionType; | 2438 propagatedType = _resolver.typeProvider.functionType; |
| 2439 } | 2439 } |
| 2440 return propagatedType2; | 2440 return propagatedType; |
| 2441 } | 2441 } |
| 2442 | 2442 |
| 2443 /** | 2443 /** |
| 2444 * Return the static type of the given expression that is to be used for type
analysis. | 2444 * Return the static type of the given expression that is to be used for type
analysis. |
| 2445 * @param expression the expression whose type is to be returned | 2445 * @param expression the expression whose type is to be returned |
| 2446 * @return the type of the given expression | 2446 * @return the type of the given expression |
| 2447 */ | 2447 */ |
| 2448 Type2 getStaticType(Expression expression) { | 2448 Type2 getStaticType(Expression expression) { |
| 2449 if (expression is NullLiteral) { | 2449 if (expression is NullLiteral) { |
| 2450 return _resolver.typeProvider.objectType; | 2450 return _resolver.typeProvider.objectType; |
| 2451 } | 2451 } |
| 2452 Type2 staticType2 = resolveTypeVariable(expression.staticType); | 2452 Type2 staticType = resolveTypeVariable(expression.staticType); |
| 2453 if (staticType2 is FunctionType) { | 2453 if (staticType is FunctionType) { |
| 2454 staticType2 = _resolver.typeProvider.functionType; | 2454 staticType = _resolver.typeProvider.functionType; |
| 2455 } | 2455 } |
| 2456 return staticType2; | 2456 return staticType; |
| 2457 } | 2457 } |
| 2458 | 2458 |
| 2459 /** | 2459 /** |
| 2460 * Return the element representing the superclass of the given class. | 2460 * Return the element representing the superclass of the given class. |
| 2461 * @param targetClass the class whose superclass is to be returned | 2461 * @param targetClass the class whose superclass is to be returned |
| 2462 * @return the element representing the superclass of the given class | 2462 * @return the element representing the superclass of the given class |
| 2463 */ | 2463 */ |
| 2464 ClassElement getSuperclass(ClassElement targetClass) { | 2464 ClassElement getSuperclass(ClassElement targetClass) { |
| 2465 InterfaceType superType = targetClass.supertype; | 2465 InterfaceType superType = targetClass.supertype; |
| 2466 if (superType == null) { | 2466 if (superType == null) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 * @param methodName the name of the operator associated with the context of u
sing of the given | 2507 * @param methodName the name of the operator associated with the context of u
sing of the given |
| 2508 * index expression | 2508 * index expression |
| 2509 * @return {@code true} if and only if an error code is generated on the passe
d node | 2509 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 2510 */ | 2510 */ |
| 2511 bool lookUpCheckIndexOperator(IndexExpression node, Expression target, String
methodName, Type2 staticType, Type2 propagatedType) { | 2511 bool lookUpCheckIndexOperator(IndexExpression node, Expression target, String
methodName, Type2 staticType, Type2 propagatedType) { |
| 2512 MethodElement staticMethod = lookUpMethod(target, staticType, methodName); | 2512 MethodElement staticMethod = lookUpMethod(target, staticType, methodName); |
| 2513 MethodElement propagatedMethod = lookUpMethod(target, propagatedType, method
Name); | 2513 MethodElement propagatedMethod = lookUpMethod(target, propagatedType, method
Name); |
| 2514 node.staticElement = staticMethod; | 2514 node.staticElement = staticMethod; |
| 2515 node.element = select3(staticMethod, propagatedMethod); | 2515 node.element = select3(staticMethod, propagatedMethod); |
| 2516 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { | 2516 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { |
| 2517 sc.Token leftBracket2 = node.leftBracket; | 2517 sc.Token leftBracket = node.leftBracket; |
| 2518 sc.Token rightBracket2 = node.rightBracket; | 2518 sc.Token rightBracket = node.rightBracket; |
| 2519 if (leftBracket2 == null || rightBracket2 == null) { | 2519 if (leftBracket == null || rightBracket == null) { |
| 2520 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_OPERATOR, node, [m
ethodName, staticType.displayName]); | 2520 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_OPERATOR, node, [m
ethodName, staticType.displayName]); |
| 2521 return true; | 2521 return true; |
| 2522 } else { | 2522 } else { |
| 2523 int offset2 = leftBracket2.offset; | 2523 int offset = leftBracket.offset; |
| 2524 int length = rightBracket2.offset - offset2 + 1; | 2524 int length = rightBracket.offset - offset + 1; |
| 2525 _resolver.reportError5(StaticTypeWarningCode.UNDEFINED_OPERATOR, offset2
, length, [methodName, staticType.displayName]); | 2525 _resolver.reportError5(StaticTypeWarningCode.UNDEFINED_OPERATOR, offset,
length, [methodName, staticType.displayName]); |
| 2526 return true; | 2526 return true; |
| 2527 } | 2527 } |
| 2528 } | 2528 } |
| 2529 return false; | 2529 return false; |
| 2530 } | 2530 } |
| 2531 | 2531 |
| 2532 /** | 2532 /** |
| 2533 * Look up the getter with the given name in the given type. Return the elemen
t representing the | 2533 * Look up the getter with the given name in the given type. Return the elemen
t representing the |
| 2534 * getter that was found, or {@code null} if there is no getter with the given
name. | 2534 * getter that was found, or {@code null} if there is no getter with the given
name. |
| 2535 * @param target the target of the invocation, or {@code null} if there is no
target | 2535 * @param target the target of the invocation, or {@code null} if there is no
target |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2582 if (getter != null) { | 2582 if (getter != null) { |
| 2583 return getter; | 2583 return getter; |
| 2584 } | 2584 } |
| 2585 } | 2585 } |
| 2586 for (InterfaceType mixinType in targetType.mixins) { | 2586 for (InterfaceType mixinType in targetType.mixins) { |
| 2587 PropertyAccessorElement getter = lookUpGetterInInterfaces(mixinType, true,
getterName, visitedInterfaces); | 2587 PropertyAccessorElement getter = lookUpGetterInInterfaces(mixinType, true,
getterName, visitedInterfaces); |
| 2588 if (getter != null) { | 2588 if (getter != null) { |
| 2589 return getter; | 2589 return getter; |
| 2590 } | 2590 } |
| 2591 } | 2591 } |
| 2592 InterfaceType superclass2 = targetType.superclass; | 2592 InterfaceType superclass = targetType.superclass; |
| 2593 if (superclass2 == null) { | 2593 if (superclass == null) { |
| 2594 return null; | 2594 return null; |
| 2595 } | 2595 } |
| 2596 return lookUpGetterInInterfaces(superclass2, true, getterName, visitedInterf
aces); | 2596 return lookUpGetterInInterfaces(superclass, true, getterName, visitedInterfa
ces); |
| 2597 } | 2597 } |
| 2598 | 2598 |
| 2599 /** | 2599 /** |
| 2600 * Look up the method or getter with the given name in the given type. Return
the element | 2600 * Look up the method or getter with the given name in the given type. Return
the element |
| 2601 * representing the method or getter that was found, or {@code null} if there
is no method or | 2601 * representing the method or getter that was found, or {@code null} if there
is no method or |
| 2602 * getter with the given name. | 2602 * getter with the given name. |
| 2603 * @param type the type in which the method or getter is defined | 2603 * @param type the type in which the method or getter is defined |
| 2604 * @param memberName the name of the method or getter being looked up | 2604 * @param memberName the name of the method or getter being looked up |
| 2605 * @return the element representing the method or getter that was found | 2605 * @return the element representing the method or getter that was found |
| 2606 */ | 2606 */ |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 if (member != null) { | 2653 if (member != null) { |
| 2654 return member; | 2654 return member; |
| 2655 } | 2655 } |
| 2656 } | 2656 } |
| 2657 for (InterfaceType mixinType in targetType.mixins) { | 2657 for (InterfaceType mixinType in targetType.mixins) { |
| 2658 ExecutableElement member = lookUpGetterOrMethodInInterfaces(mixinType, tru
e, memberName, visitedInterfaces); | 2658 ExecutableElement member = lookUpGetterOrMethodInInterfaces(mixinType, tru
e, memberName, visitedInterfaces); |
| 2659 if (member != null) { | 2659 if (member != null) { |
| 2660 return member; | 2660 return member; |
| 2661 } | 2661 } |
| 2662 } | 2662 } |
| 2663 InterfaceType superclass2 = targetType.superclass; | 2663 InterfaceType superclass = targetType.superclass; |
| 2664 if (superclass2 == null) { | 2664 if (superclass == null) { |
| 2665 return null; | 2665 return null; |
| 2666 } | 2666 } |
| 2667 return lookUpGetterOrMethodInInterfaces(superclass2, true, memberName, visit
edInterfaces); | 2667 return lookUpGetterOrMethodInInterfaces(superclass, true, memberName, visite
dInterfaces); |
| 2668 } | 2668 } |
| 2669 | 2669 |
| 2670 /** | 2670 /** |
| 2671 * Find the element corresponding to the given label node in the current label
scope. | 2671 * Find the element corresponding to the given label node in the current label
scope. |
| 2672 * @param parentNode the node containing the given label | 2672 * @param parentNode the node containing the given label |
| 2673 * @param labelNode the node representing the label being looked up | 2673 * @param labelNode the node representing the label being looked up |
| 2674 * @return the element corresponding to the given label node in the current sc
ope | 2674 * @return the element corresponding to the given label node in the current sc
ope |
| 2675 */ | 2675 */ |
| 2676 LabelElementImpl lookupLabel(ASTNode parentNode, SimpleIdentifier labelNode) { | 2676 LabelElementImpl lookupLabel(ASTNode parentNode, SimpleIdentifier labelNode) { |
| 2677 LabelScope labelScope2 = _resolver.labelScope; | 2677 LabelScope labelScope = _resolver.labelScope; |
| 2678 LabelElementImpl labelElement = null; | 2678 LabelElementImpl labelElement = null; |
| 2679 if (labelNode == null) { | 2679 if (labelNode == null) { |
| 2680 if (labelScope2 == null) { | 2680 if (labelScope == null) { |
| 2681 } else { | 2681 } else { |
| 2682 labelElement = labelScope2.lookup2(LabelScope.EMPTY_LABEL) as LabelEleme
ntImpl; | 2682 labelElement = labelScope.lookup2(LabelScope.EMPTY_LABEL) as LabelElemen
tImpl; |
| 2683 if (labelElement == null) { | 2683 if (labelElement == null) { |
| 2684 } | 2684 } |
| 2685 labelElement = null; | 2685 labelElement = null; |
| 2686 } | 2686 } |
| 2687 } else { | 2687 } else { |
| 2688 if (labelScope2 == null) { | 2688 if (labelScope == null) { |
| 2689 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode, [
labelNode.name]); | 2689 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode, [
labelNode.name]); |
| 2690 } else { | 2690 } else { |
| 2691 labelElement = labelScope2.lookup(labelNode) as LabelElementImpl; | 2691 labelElement = labelScope.lookup(labelNode) as LabelElementImpl; |
| 2692 if (labelElement == null) { | 2692 if (labelElement == null) { |
| 2693 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode,
[labelNode.name]); | 2693 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode,
[labelNode.name]); |
| 2694 } else { | 2694 } else { |
| 2695 recordResolution(labelNode, labelElement); | 2695 recordResolution(labelNode, labelElement); |
| 2696 } | 2696 } |
| 2697 } | 2697 } |
| 2698 } | 2698 } |
| 2699 if (labelElement != null) { | 2699 if (labelElement != null) { |
| 2700 ExecutableElement labelContainer = labelElement.getAncestor(ExecutableElem
ent); | 2700 ExecutableElement labelContainer = labelElement.getAncestor(ExecutableElem
ent); |
| 2701 if (labelContainer != _resolver.enclosingFunction) { | 2701 if (labelContainer != _resolver.enclosingFunction) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2759 if (method != null) { | 2759 if (method != null) { |
| 2760 return method; | 2760 return method; |
| 2761 } | 2761 } |
| 2762 } | 2762 } |
| 2763 for (InterfaceType mixinType in targetType.mixins) { | 2763 for (InterfaceType mixinType in targetType.mixins) { |
| 2764 MethodElement method = lookUpMethodInInterfaces(mixinType, true, methodNam
e, visitedInterfaces); | 2764 MethodElement method = lookUpMethodInInterfaces(mixinType, true, methodNam
e, visitedInterfaces); |
| 2765 if (method != null) { | 2765 if (method != null) { |
| 2766 return method; | 2766 return method; |
| 2767 } | 2767 } |
| 2768 } | 2768 } |
| 2769 InterfaceType superclass2 = targetType.superclass; | 2769 InterfaceType superclass = targetType.superclass; |
| 2770 if (superclass2 == null) { | 2770 if (superclass == null) { |
| 2771 return null; | 2771 return null; |
| 2772 } | 2772 } |
| 2773 return lookUpMethodInInterfaces(superclass2, true, methodName, visitedInterf
aces); | 2773 return lookUpMethodInInterfaces(superclass, true, methodName, visitedInterfa
ces); |
| 2774 } | 2774 } |
| 2775 | 2775 |
| 2776 /** | 2776 /** |
| 2777 * Look up the setter with the given name in the given type. Return the elemen
t representing the | 2777 * Look up the setter with the given name in the given type. Return the elemen
t representing the |
| 2778 * setter that was found, or {@code null} if there is no setter with the given
name. | 2778 * setter that was found, or {@code null} if there is no setter with the given
name. |
| 2779 * @param target the target of the invocation, or {@code null} if there is no
target | 2779 * @param target the target of the invocation, or {@code null} if there is no
target |
| 2780 * @param type the type in which the setter is defined | 2780 * @param type the type in which the setter is defined |
| 2781 * @param setterName the name of the setter being looked up | 2781 * @param setterName the name of the setter being looked up |
| 2782 * @return the element representing the setter that was found | 2782 * @return the element representing the setter that was found |
| 2783 */ | 2783 */ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2826 if (setter != null) { | 2826 if (setter != null) { |
| 2827 return setter; | 2827 return setter; |
| 2828 } | 2828 } |
| 2829 } | 2829 } |
| 2830 for (InterfaceType mixinType in targetType.mixins) { | 2830 for (InterfaceType mixinType in targetType.mixins) { |
| 2831 PropertyAccessorElement setter = lookUpSetterInInterfaces(mixinType, true,
setterName, visitedInterfaces); | 2831 PropertyAccessorElement setter = lookUpSetterInInterfaces(mixinType, true,
setterName, visitedInterfaces); |
| 2832 if (setter != null) { | 2832 if (setter != null) { |
| 2833 return setter; | 2833 return setter; |
| 2834 } | 2834 } |
| 2835 } | 2835 } |
| 2836 InterfaceType superclass2 = targetType.superclass; | 2836 InterfaceType superclass = targetType.superclass; |
| 2837 if (superclass2 == null) { | 2837 if (superclass == null) { |
| 2838 return null; | 2838 return null; |
| 2839 } | 2839 } |
| 2840 return lookUpSetterInInterfaces(superclass2, true, setterName, visitedInterf
aces); | 2840 return lookUpSetterInInterfaces(superclass, true, setterName, visitedInterfa
ces); |
| 2841 } | 2841 } |
| 2842 | 2842 |
| 2843 /** | 2843 /** |
| 2844 * Return the binary operator that is invoked by the given compound assignment
operator. | 2844 * Return the binary operator that is invoked by the given compound assignment
operator. |
| 2845 * @param operator the assignment operator being mapped | 2845 * @param operator the assignment operator being mapped |
| 2846 * @return the binary operator that invoked by the given assignment operator | 2846 * @return the binary operator that invoked by the given assignment operator |
| 2847 */ | 2847 */ |
| 2848 sc.TokenType operatorFromCompoundAssignment(sc.TokenType operator) { | 2848 sc.TokenType operatorFromCompoundAssignment(sc.TokenType operator) { |
| 2849 while (true) { | 2849 while (true) { |
| 2850 if (operator == sc.TokenType.AMPERSAND_EQ) { | 2850 if (operator == sc.TokenType.AMPERSAND_EQ) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2906 * correspond to the arguments, or {@code null} if no correspondence could be
computed. | 2906 * correspond to the arguments, or {@code null} if no correspondence could be
computed. |
| 2907 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false}then compile-time warning | 2907 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false}then compile-time warning |
| 2908 * @param argumentList the list of arguments being passed to the element | 2908 * @param argumentList the list of arguments being passed to the element |
| 2909 * @param executableElement the element that will be invoked with the argument
s | 2909 * @param executableElement the element that will be invoked with the argument
s |
| 2910 * @return the parameters that correspond to the arguments | 2910 * @return the parameters that correspond to the arguments |
| 2911 */ | 2911 */ |
| 2912 List<ParameterElement> resolveArgumentsToParameters(bool reportError, Argument
List argumentList, ExecutableElement executableElement) { | 2912 List<ParameterElement> resolveArgumentsToParameters(bool reportError, Argument
List argumentList, ExecutableElement executableElement) { |
| 2913 if (executableElement == null) { | 2913 if (executableElement == null) { |
| 2914 return null; | 2914 return null; |
| 2915 } | 2915 } |
| 2916 List<ParameterElement> parameters2 = executableElement.parameters; | 2916 List<ParameterElement> parameters = executableElement.parameters; |
| 2917 return resolveArgumentsToParameters2(reportError, argumentList, parameters2)
; | 2917 return resolveArgumentsToParameters2(reportError, argumentList, parameters); |
| 2918 } | 2918 } |
| 2919 | 2919 |
| 2920 /** | 2920 /** |
| 2921 * Given a list of arguments and the parameters related to the element that wi
ll be invoked using | 2921 * Given a list of arguments and the parameters related to the element that wi
ll be invoked using |
| 2922 * those argument, compute the list of parameters that correspond to the list
of arguments. Return | 2922 * those argument, compute the list of parameters that correspond to the list
of arguments. Return |
| 2923 * the parameters that correspond to the arguments. | 2923 * the parameters that correspond to the arguments. |
| 2924 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false}then compile-time warning | 2924 * @param reportError if {@code true} then compile-time error should be report
ed; if {@code false}then compile-time warning |
| 2925 * @param argumentList the list of arguments being passed to the element | 2925 * @param argumentList the list of arguments being passed to the element |
| 2926 * @param parameters the of the function that will be invoked with the argumen
ts | 2926 * @param parameters the of the function that will be invoked with the argumen
ts |
| 2927 * @return the parameters that correspond to the arguments | 2927 * @return the parameters that correspond to the arguments |
| 2928 */ | 2928 */ |
| 2929 List<ParameterElement> resolveArgumentsToParameters2(bool reportError2, Argume
ntList argumentList, List<ParameterElement> parameters) { | 2929 List<ParameterElement> resolveArgumentsToParameters2(bool reportError2, Argume
ntList argumentList, List<ParameterElement> parameters) { |
| 2930 List<ParameterElement> requiredParameters = new List<ParameterElement>(); | 2930 List<ParameterElement> requiredParameters = new List<ParameterElement>(); |
| 2931 List<ParameterElement> positionalParameters = new List<ParameterElement>(); | 2931 List<ParameterElement> positionalParameters = new List<ParameterElement>(); |
| 2932 Map<String, ParameterElement> namedParameters = new Map<String, ParameterEle
ment>(); | 2932 Map<String, ParameterElement> namedParameters = new Map<String, ParameterEle
ment>(); |
| 2933 for (ParameterElement parameter in parameters) { | 2933 for (ParameterElement parameter in parameters) { |
| 2934 ParameterKind kind = parameter.parameterKind; | 2934 ParameterKind kind = parameter.parameterKind; |
| 2935 if (identical(kind, ParameterKind.REQUIRED)) { | 2935 if (identical(kind, ParameterKind.REQUIRED)) { |
| 2936 requiredParameters.add(parameter); | 2936 requiredParameters.add(parameter); |
| 2937 } else if (identical(kind, ParameterKind.POSITIONAL)) { | 2937 } else if (identical(kind, ParameterKind.POSITIONAL)) { |
| 2938 positionalParameters.add(parameter); | 2938 positionalParameters.add(parameter); |
| 2939 } else { | 2939 } else { |
| 2940 namedParameters[parameter.name] = parameter; | 2940 namedParameters[parameter.name] = parameter; |
| 2941 } | 2941 } |
| 2942 } | 2942 } |
| 2943 List<ParameterElement> unnamedParameters = new List<ParameterElement>.from(r
equiredParameters); | 2943 List<ParameterElement> unnamedParameters = new List<ParameterElement>.from(r
equiredParameters); |
| 2944 unnamedParameters.addAll(positionalParameters); | 2944 unnamedParameters.addAll(positionalParameters); |
| 2945 int unnamedParameterCount = unnamedParameters.length; | 2945 int unnamedParameterCount = unnamedParameters.length; |
| 2946 int unnamedIndex = 0; | 2946 int unnamedIndex = 0; |
| 2947 NodeList<Expression> arguments2 = argumentList.arguments; | 2947 NodeList<Expression> arguments = argumentList.arguments; |
| 2948 int argumentCount = arguments2.length; | 2948 int argumentCount = arguments.length; |
| 2949 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum
entCount); | 2949 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum
entCount); |
| 2950 int positionalArgumentCount = 0; | 2950 int positionalArgumentCount = 0; |
| 2951 Set<String> usedNames = new Set<String>(); | 2951 Set<String> usedNames = new Set<String>(); |
| 2952 for (int i = 0; i < argumentCount; i++) { | 2952 for (int i = 0; i < argumentCount; i++) { |
| 2953 Expression argument = arguments2[i]; | 2953 Expression argument = arguments[i]; |
| 2954 if (argument is NamedExpression) { | 2954 if (argument is NamedExpression) { |
| 2955 SimpleIdentifier nameNode = ((argument as NamedExpression)).name.label; | 2955 SimpleIdentifier nameNode = ((argument as NamedExpression)).name.label; |
| 2956 String name2 = nameNode.name; | 2956 String name = nameNode.name; |
| 2957 ParameterElement element = namedParameters[name2]; | 2957 ParameterElement element = namedParameters[name]; |
| 2958 if (element == null) { | 2958 if (element == null) { |
| 2959 ErrorCode errorCode = reportError2 ? CompileTimeErrorCode.UNDEFINED_NA
MED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER; | 2959 ErrorCode errorCode = reportError2 ? CompileTimeErrorCode.UNDEFINED_NA
MED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER; |
| 2960 _resolver.reportError(errorCode, nameNode, [name2]); | 2960 _resolver.reportError(errorCode, nameNode, [name]); |
| 2961 } else { | 2961 } else { |
| 2962 resolvedParameters[i] = element; | 2962 resolvedParameters[i] = element; |
| 2963 recordResolution(nameNode, element); | 2963 recordResolution(nameNode, element); |
| 2964 } | 2964 } |
| 2965 if (!javaSetAdd(usedNames, name2)) { | 2965 if (!javaSetAdd(usedNames, name)) { |
| 2966 _resolver.reportError(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, n
ameNode, [name2]); | 2966 _resolver.reportError(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, n
ameNode, [name]); |
| 2967 } | 2967 } |
| 2968 } else { | 2968 } else { |
| 2969 positionalArgumentCount++; | 2969 positionalArgumentCount++; |
| 2970 if (unnamedIndex < unnamedParameterCount) { | 2970 if (unnamedIndex < unnamedParameterCount) { |
| 2971 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; | 2971 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; |
| 2972 } | 2972 } |
| 2973 } | 2973 } |
| 2974 } | 2974 } |
| 2975 if (positionalArgumentCount < requiredParameters.length) { | 2975 if (positionalArgumentCount < requiredParameters.length) { |
| 2976 ErrorCode errorCode = reportError2 ? CompileTimeErrorCode.NOT_ENOUGH_REQUI
RED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS; | 2976 ErrorCode errorCode = reportError2 ? CompileTimeErrorCode.NOT_ENOUGH_REQUI
RED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3022 if (targetType is InterfaceType) { | 3022 if (targetType is InterfaceType) { |
| 3023 InterfaceType classType = targetType as InterfaceType; | 3023 InterfaceType classType = targetType as InterfaceType; |
| 3024 Element element = lookUpMethod(target, classType, methodName.name); | 3024 Element element = lookUpMethod(target, classType, methodName.name); |
| 3025 if (element == null) { | 3025 if (element == null) { |
| 3026 element = classType.getGetter(methodName.name); | 3026 element = classType.getGetter(methodName.name); |
| 3027 } | 3027 } |
| 3028 return element; | 3028 return element; |
| 3029 } else if (target is SimpleIdentifier) { | 3029 } else if (target is SimpleIdentifier) { |
| 3030 Element targetElement = ((target as SimpleIdentifier)).element; | 3030 Element targetElement = ((target as SimpleIdentifier)).element; |
| 3031 if (targetElement is PrefixElement) { | 3031 if (targetElement is PrefixElement) { |
| 3032 String name2 = "${((target as SimpleIdentifier)).name}.${methodName}"; | 3032 String name = "${((target as SimpleIdentifier)).name}.${methodName}"; |
| 3033 Identifier functionName = new ElementResolver_SyntheticIdentifier(name2)
; | 3033 Identifier functionName = new ElementResolver_SyntheticIdentifier(name); |
| 3034 Element element = _resolver.nameScope.lookup(functionName, _resolver.def
iningLibrary); | 3034 Element element = _resolver.nameScope.lookup(functionName, _resolver.def
iningLibrary); |
| 3035 if (element != null) { | 3035 if (element != null) { |
| 3036 return element; | 3036 return element; |
| 3037 } | 3037 } |
| 3038 } | 3038 } |
| 3039 } | 3039 } |
| 3040 return null; | 3040 return null; |
| 3041 } | 3041 } |
| 3042 | 3042 |
| 3043 /** | 3043 /** |
| 3044 * Given an invocation of the form 'm(a1, ..., an)', resolve 'm' to the elemen
t being invoked. If | 3044 * Given an invocation of the form 'm(a1, ..., an)', resolve 'm' to the elemen
t being invoked. If |
| 3045 * the returned element is a method, then the method will be invoked. If the r
eturned element is a | 3045 * the returned element is a method, then the method will be invoked. If the r
eturned element is a |
| 3046 * getter, the getter will be invoked without arguments and the result of that
invocation will | 3046 * getter, the getter will be invoked without arguments and the result of that
invocation will |
| 3047 * then be invoked with the arguments. | 3047 * then be invoked with the arguments. |
| 3048 * @param methodName the name of the method being invoked ('m') | 3048 * @param methodName the name of the method being invoked ('m') |
| 3049 * @return the element being invoked | 3049 * @return the element being invoked |
| 3050 */ | 3050 */ |
| 3051 Element resolveInvokedElement2(SimpleIdentifier methodName) { | 3051 Element resolveInvokedElement2(SimpleIdentifier methodName) { |
| 3052 Element element = _resolver.nameScope.lookup(methodName, _resolver.definingL
ibrary); | 3052 Element element = _resolver.nameScope.lookup(methodName, _resolver.definingL
ibrary); |
| 3053 if (element == null) { | 3053 if (element == null) { |
| 3054 ClassElement enclosingClass2 = _resolver.enclosingClass; | 3054 ClassElement enclosingClass = _resolver.enclosingClass; |
| 3055 if (enclosingClass2 != null) { | 3055 if (enclosingClass != null) { |
| 3056 InterfaceType enclosingType = enclosingClass2.type; | 3056 InterfaceType enclosingType = enclosingClass.type; |
| 3057 element = lookUpMethod(null, enclosingType, methodName.name); | 3057 element = lookUpMethod(null, enclosingType, methodName.name); |
| 3058 if (element == null) { | 3058 if (element == null) { |
| 3059 element = lookUpGetter(null, enclosingType, methodName.name); | 3059 element = lookUpGetter(null, enclosingType, methodName.name); |
| 3060 } | 3060 } |
| 3061 } | 3061 } |
| 3062 } | 3062 } |
| 3063 return element; | 3063 return element; |
| 3064 } | 3064 } |
| 3065 | 3065 |
| 3066 /** | 3066 /** |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3119 /** | 3119 /** |
| 3120 * Resolve the given simple identifier if possible. Return the element to whic
h it could be | 3120 * Resolve the given simple identifier if possible. Return the element to whic
h it could be |
| 3121 * resolved, or {@code null} if it could not be resolved. This does not record
the results of the | 3121 * resolved, or {@code null} if it could not be resolved. This does not record
the results of the |
| 3122 * resolution. | 3122 * resolution. |
| 3123 * @param node the identifier to be resolved | 3123 * @param node the identifier to be resolved |
| 3124 * @return the element to which the identifier could be resolved | 3124 * @return the element to which the identifier could be resolved |
| 3125 */ | 3125 */ |
| 3126 Element resolveSimpleIdentifier(SimpleIdentifier node) { | 3126 Element resolveSimpleIdentifier(SimpleIdentifier node) { |
| 3127 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibrary
); | 3127 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibrary
); |
| 3128 if (element is PropertyAccessorElement && node.inSetterContext()) { | 3128 if (element is PropertyAccessorElement && node.inSetterContext()) { |
| 3129 PropertyInducingElement variable2 = ((element as PropertyAccessorElement))
.variable; | 3129 PropertyInducingElement variable = ((element as PropertyAccessorElement)).
variable; |
| 3130 if (variable2 != null) { | 3130 if (variable != null) { |
| 3131 PropertyAccessorElement setter2 = variable2.setter; | 3131 PropertyAccessorElement setter = variable.setter; |
| 3132 if (setter2 == null) { | 3132 if (setter == null) { |
| 3133 ClassElement enclosingClass2 = _resolver.enclosingClass; | 3133 ClassElement enclosingClass = _resolver.enclosingClass; |
| 3134 if (enclosingClass2 != null) { | 3134 if (enclosingClass != null) { |
| 3135 setter2 = lookUpSetter(null, enclosingClass2.type, node.name); | 3135 setter = lookUpSetter(null, enclosingClass.type, node.name); |
| 3136 } | 3136 } |
| 3137 } | 3137 } |
| 3138 if (setter2 != null) { | 3138 if (setter != null) { |
| 3139 element = setter2; | 3139 element = setter; |
| 3140 } | 3140 } |
| 3141 } | 3141 } |
| 3142 } else if (element == null && node.inSetterContext()) { | 3142 } else if (element == null && node.inSetterContext()) { |
| 3143 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdentifi
er("${node.name}="), _resolver.definingLibrary); | 3143 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdentifi
er("${node.name}="), _resolver.definingLibrary); |
| 3144 } | 3144 } |
| 3145 ClassElement enclosingClass3 = _resolver.enclosingClass; | 3145 ClassElement enclosingClass = _resolver.enclosingClass; |
| 3146 if (element == null && enclosingClass3 != null) { | 3146 if (element == null && enclosingClass != null) { |
| 3147 InterfaceType enclosingType = enclosingClass3.type; | 3147 InterfaceType enclosingType = enclosingClass.type; |
| 3148 if (element == null && node.inSetterContext()) { | 3148 if (element == null && node.inSetterContext()) { |
| 3149 element = lookUpSetter(null, enclosingType, node.name); | 3149 element = lookUpSetter(null, enclosingType, node.name); |
| 3150 } | 3150 } |
| 3151 if (element == null && node.inGetterContext()) { | 3151 if (element == null && node.inGetterContext()) { |
| 3152 element = lookUpGetter(null, enclosingType, node.name); | 3152 element = lookUpGetter(null, enclosingType, node.name); |
| 3153 } | 3153 } |
| 3154 if (element == null) { | 3154 if (element == null) { |
| 3155 element = lookUpMethod(null, enclosingType, node.name); | 3155 element = lookUpMethod(null, enclosingType, node.name); |
| 3156 } | 3156 } |
| 3157 } | 3157 } |
| 3158 return element; | 3158 return element; |
| 3159 } | 3159 } |
| 3160 | 3160 |
| 3161 /** | 3161 /** |
| 3162 * If the given type is a type variable, resolve it to the type that should be
used when looking | 3162 * If the given type is a type variable, resolve it to the type that should be
used when looking |
| 3163 * up members. Otherwise, return the original type. | 3163 * up members. Otherwise, return the original type. |
| 3164 * @param type the type that is to be resolved if it is a type variable | 3164 * @param type the type that is to be resolved if it is a type variable |
| 3165 * @return the type that should be used in place of the argument if it is a ty
pe variable, or the | 3165 * @return the type that should be used in place of the argument if it is a ty
pe variable, or the |
| 3166 * original argument if it isn't a type variable | 3166 * original argument if it isn't a type variable |
| 3167 */ | 3167 */ |
| 3168 Type2 resolveTypeVariable(Type2 type) { | 3168 Type2 resolveTypeVariable(Type2 type) { |
| 3169 if (type is TypeVariableType) { | 3169 if (type is TypeVariableType) { |
| 3170 Type2 bound2 = ((type as TypeVariableType)).element.bound; | 3170 Type2 bound = ((type as TypeVariableType)).element.bound; |
| 3171 if (bound2 == null) { | 3171 if (bound == null) { |
| 3172 return _resolver.typeProvider.objectType; | 3172 return _resolver.typeProvider.objectType; |
| 3173 } | 3173 } |
| 3174 return bound2; | 3174 return bound; |
| 3175 } | 3175 } |
| 3176 return type; | 3176 return type; |
| 3177 } | 3177 } |
| 3178 | 3178 |
| 3179 /** | 3179 /** |
| 3180 * Given two possible error codes for the same piece of code, one computed usi
ng static type | 3180 * Given two possible error codes for the same piece of code, one computed usi
ng static type |
| 3181 * information and the other using propagated type information, return the err
or code that should | 3181 * information and the other using propagated type information, return the err
or code that should |
| 3182 * be reported, or {@code null} if no error should be reported. | 3182 * be reported, or {@code null} if no error should be reported. |
| 3183 * @param staticError the error code computed using static type information | 3183 * @param staticError the error code computed using static type information |
| 3184 * @param propagatedError the error code computed using propagated type inform
ation | 3184 * @param propagatedError the error code computed using propagated type inform
ation |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3427 * @return a mapping between the set of all string names of the members inheri
ted from the passed{@link ClassElement} superclass hierarchy, and the associated
{@link ExecutableElement} | 3427 * @return a mapping between the set of all string names of the members inheri
ted from the passed{@link ClassElement} superclass hierarchy, and the associated
{@link ExecutableElement} |
| 3428 */ | 3428 */ |
| 3429 Map<String, ExecutableElement> computeClassChainLookupMap(ClassElement classEl
t, Set<ClassElement> visitedClasses) { | 3429 Map<String, ExecutableElement> computeClassChainLookupMap(ClassElement classEl
t, Set<ClassElement> visitedClasses) { |
| 3430 Map<String, ExecutableElement> resultMap = _classLookup[classElt]; | 3430 Map<String, ExecutableElement> resultMap = _classLookup[classElt]; |
| 3431 if (resultMap != null) { | 3431 if (resultMap != null) { |
| 3432 return resultMap; | 3432 return resultMap; |
| 3433 } else { | 3433 } else { |
| 3434 resultMap = new Map<String, ExecutableElement>(); | 3434 resultMap = new Map<String, ExecutableElement>(); |
| 3435 } | 3435 } |
| 3436 ClassElement superclassElt = null; | 3436 ClassElement superclassElt = null; |
| 3437 InterfaceType supertype2 = classElt.supertype; | 3437 InterfaceType supertype = classElt.supertype; |
| 3438 if (supertype2 != null) { | 3438 if (supertype != null) { |
| 3439 superclassElt = supertype2.element; | 3439 superclassElt = supertype.element; |
| 3440 } else { | 3440 } else { |
| 3441 _classLookup[classElt] = resultMap; | 3441 _classLookup[classElt] = resultMap; |
| 3442 return resultMap; | 3442 return resultMap; |
| 3443 } | 3443 } |
| 3444 if (superclassElt != null) { | 3444 if (superclassElt != null) { |
| 3445 if (!visitedClasses.contains(superclassElt)) { | 3445 if (!visitedClasses.contains(superclassElt)) { |
| 3446 javaSetAdd(visitedClasses, classElt); | 3446 javaSetAdd(visitedClasses, classElt); |
| 3447 resultMap = new Map<String, ExecutableElement>.from(computeClassChainLoo
kupMap(superclassElt, visitedClasses)); | 3447 resultMap = new Map<String, ExecutableElement>.from(computeClassChainLoo
kupMap(superclassElt, visitedClasses)); |
| 3448 } else { | 3448 } else { |
| 3449 _classLookup[superclassElt] = resultMap; | 3449 _classLookup[superclassElt] = resultMap; |
| 3450 return resultMap; | 3450 return resultMap; |
| 3451 } | 3451 } |
| 3452 recordMapWithClassMembers(resultMap, superclassElt); | 3452 recordMapWithClassMembers(resultMap, superclassElt); |
| 3453 } | 3453 } |
| 3454 List<InterfaceType> mixins2 = classElt.mixins; | 3454 List<InterfaceType> mixins = classElt.mixins; |
| 3455 for (int i = mixins2.length - 1; i >= 0; i--) { | 3455 for (int i = mixins.length - 1; i >= 0; i--) { |
| 3456 ClassElement mixinElement = mixins2[i].element; | 3456 ClassElement mixinElement = mixins[i].element; |
| 3457 if (mixinElement != null) { | 3457 if (mixinElement != null) { |
| 3458 recordMapWithClassMembers(resultMap, mixinElement); | 3458 recordMapWithClassMembers(resultMap, mixinElement); |
| 3459 } | 3459 } |
| 3460 } | 3460 } |
| 3461 _classLookup[classElt] = resultMap; | 3461 _classLookup[classElt] = resultMap; |
| 3462 return resultMap; | 3462 return resultMap; |
| 3463 } | 3463 } |
| 3464 | 3464 |
| 3465 /** | 3465 /** |
| 3466 * Compute and return the inheritance path given the context of a type and a m
ember that is | 3466 * Compute and return the inheritance path given the context of a type and a m
ember that is |
| 3467 * overridden in the inheritance path (for which the type is in the path). | 3467 * overridden in the inheritance path (for which the type is in the path). |
| 3468 * @param chain the inheritance path that is built up as this method calls its
elf recursively, | 3468 * @param chain the inheritance path that is built up as this method calls its
elf recursively, |
| 3469 * when this method is called an empty {@link LinkedList} should be provided | 3469 * when this method is called an empty {@link LinkedList} should be provided |
| 3470 * @param currentType the current type in the inheritance path | 3470 * @param currentType the current type in the inheritance path |
| 3471 * @param memberName the name of the member that is being looked up the inheri
tance path | 3471 * @param memberName the name of the member that is being looked up the inheri
tance path |
| 3472 */ | 3472 */ |
| 3473 void computeInheritancePath(Queue<InterfaceType> chain, InterfaceType currentT
ype, String memberName) { | 3473 void computeInheritancePath(Queue<InterfaceType> chain, InterfaceType currentT
ype, String memberName) { |
| 3474 chain.add(currentType); | 3474 chain.add(currentType); |
| 3475 ClassElement classElt = currentType.element; | 3475 ClassElement classElt = currentType.element; |
| 3476 InterfaceType supertype2 = classElt.supertype; | 3476 InterfaceType supertype = classElt.supertype; |
| 3477 if (supertype2 == null) { | 3477 if (supertype == null) { |
| 3478 return; | 3478 return; |
| 3479 } | 3479 } |
| 3480 if (chain.length != 1) { | 3480 if (chain.length != 1) { |
| 3481 if (lookupMemberInClass(classElt, memberName) != null) { | 3481 if (lookupMemberInClass(classElt, memberName) != null) { |
| 3482 return; | 3482 return; |
| 3483 } | 3483 } |
| 3484 } | 3484 } |
| 3485 List<InterfaceType> mixins2 = classElt.mixins; | 3485 List<InterfaceType> mixins = classElt.mixins; |
| 3486 for (int i = mixins2.length - 1; i >= 0; i--) { | 3486 for (int i = mixins.length - 1; i >= 0; i--) { |
| 3487 ClassElement mixinElement = mixins2[i].element; | 3487 ClassElement mixinElement = mixins[i].element; |
| 3488 if (mixinElement != null) { | 3488 if (mixinElement != null) { |
| 3489 ExecutableElement elt = lookupMemberInClass(mixinElement, memberName); | 3489 ExecutableElement elt = lookupMemberInClass(mixinElement, memberName); |
| 3490 if (elt != null) { | 3490 if (elt != null) { |
| 3491 chain.add(mixins2[i]); | 3491 chain.add(mixins[i]); |
| 3492 return; | 3492 return; |
| 3493 } | 3493 } |
| 3494 } | 3494 } |
| 3495 } | 3495 } |
| 3496 ClassElement superclassElt = supertype2.element; | 3496 ClassElement superclassElt = supertype.element; |
| 3497 if (lookupMember(superclassElt, memberName) != null) { | 3497 if (lookupMember(superclassElt, memberName) != null) { |
| 3498 computeInheritancePath(chain, supertype2, memberName); | 3498 computeInheritancePath(chain, supertype, memberName); |
| 3499 return; | 3499 return; |
| 3500 } | 3500 } |
| 3501 List<InterfaceType> interfaces2 = classElt.interfaces; | 3501 List<InterfaceType> interfaces = classElt.interfaces; |
| 3502 for (InterfaceType interfaceType in interfaces2) { | 3502 for (InterfaceType interfaceType in interfaces) { |
| 3503 ClassElement interfaceElement = interfaceType.element; | 3503 ClassElement interfaceElement = interfaceType.element; |
| 3504 if (interfaceElement != null && lookupMember(interfaceElement, memberName)
!= null) { | 3504 if (interfaceElement != null && lookupMember(interfaceElement, memberName)
!= null) { |
| 3505 computeInheritancePath(chain, interfaceType, memberName); | 3505 computeInheritancePath(chain, interfaceType, memberName); |
| 3506 return; | 3506 return; |
| 3507 } | 3507 } |
| 3508 } | 3508 } |
| 3509 } | 3509 } |
| 3510 | 3510 |
| 3511 /** | 3511 /** |
| 3512 * Compute and return a mapping between the set of all string names of the mem
bers inherited from | 3512 * Compute and return a mapping between the set of all string names of the mem
bers inherited from |
| 3513 * the passed {@link ClassElement} interface hierarchy, and the associated{@li
nk ExecutableElement}. | 3513 * the passed {@link ClassElement} interface hierarchy, and the associated{@li
nk ExecutableElement}. |
| 3514 * @param classElt the class element to query | 3514 * @param classElt the class element to query |
| 3515 * @param visitedInterfaces a set of visited classes passed back into this met
hod when it calls | 3515 * @param visitedInterfaces a set of visited classes passed back into this met
hod when it calls |
| 3516 * itself recursively | 3516 * itself recursively |
| 3517 * @return a mapping between the set of all string names of the members inheri
ted from the passed{@link ClassElement} interface hierarchy, and the associated
{@link ExecutableElement} | 3517 * @return a mapping between the set of all string names of the members inheri
ted from the passed{@link ClassElement} interface hierarchy, and the associated
{@link ExecutableElement} |
| 3518 */ | 3518 */ |
| 3519 Map<String, ExecutableElement> computeInterfaceLookupMap(ClassElement classElt
, Set<ClassElement> visitedInterfaces) { | 3519 Map<String, ExecutableElement> computeInterfaceLookupMap(ClassElement classElt
, Set<ClassElement> visitedInterfaces) { |
| 3520 Map<String, ExecutableElement> resultMap = _interfaceLookup[classElt]; | 3520 Map<String, ExecutableElement> resultMap = _interfaceLookup[classElt]; |
| 3521 if (resultMap != null) { | 3521 if (resultMap != null) { |
| 3522 return resultMap; | 3522 return resultMap; |
| 3523 } else { | 3523 } else { |
| 3524 resultMap = new Map<String, ExecutableElement>(); | 3524 resultMap = new Map<String, ExecutableElement>(); |
| 3525 } | 3525 } |
| 3526 InterfaceType supertype2 = classElt.supertype; | 3526 InterfaceType supertype = classElt.supertype; |
| 3527 ClassElement superclassElement = supertype2 != null ? supertype2.element : n
ull; | 3527 ClassElement superclassElement = supertype != null ? supertype.element : nul
l; |
| 3528 List<InterfaceType> interfaces2 = classElt.interfaces; | 3528 List<InterfaceType> interfaces = classElt.interfaces; |
| 3529 if (superclassElement == null || interfaces2.length == 0) { | 3529 if (superclassElement == null || interfaces.length == 0) { |
| 3530 _interfaceLookup[classElt] = resultMap; | 3530 _interfaceLookup[classElt] = resultMap; |
| 3531 return resultMap; | 3531 return resultMap; |
| 3532 } | 3532 } |
| 3533 List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, Execu
tableElement>>(); | 3533 List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, Execu
tableElement>>(); |
| 3534 if (superclassElement != null) { | 3534 if (superclassElement != null) { |
| 3535 if (!visitedInterfaces.contains(superclassElement)) { | 3535 if (!visitedInterfaces.contains(superclassElement)) { |
| 3536 try { | 3536 try { |
| 3537 javaSetAdd(visitedInterfaces, superclassElement); | 3537 javaSetAdd(visitedInterfaces, superclassElement); |
| 3538 lookupMaps.add(computeInterfaceLookupMap(superclassElement, visitedInt
erfaces)); | 3538 lookupMaps.add(computeInterfaceLookupMap(superclassElement, visitedInt
erfaces)); |
| 3539 } finally { | 3539 } finally { |
| 3540 visitedInterfaces.remove(superclassElement); | 3540 visitedInterfaces.remove(superclassElement); |
| 3541 } | 3541 } |
| 3542 } else { | 3542 } else { |
| 3543 Map<String, ExecutableElement> map = _interfaceLookup[classElt]; | 3543 Map<String, ExecutableElement> map = _interfaceLookup[classElt]; |
| 3544 if (map != null) { | 3544 if (map != null) { |
| 3545 lookupMaps.add(map); | 3545 lookupMaps.add(map); |
| 3546 } else { | 3546 } else { |
| 3547 _interfaceLookup[superclassElement] = resultMap; | 3547 _interfaceLookup[superclassElement] = resultMap; |
| 3548 return resultMap; | 3548 return resultMap; |
| 3549 } | 3549 } |
| 3550 } | 3550 } |
| 3551 } | 3551 } |
| 3552 for (InterfaceType interfaceType in interfaces2) { | 3552 for (InterfaceType interfaceType in interfaces) { |
| 3553 ClassElement interfaceElement = interfaceType.element; | 3553 ClassElement interfaceElement = interfaceType.element; |
| 3554 if (interfaceElement != null) { | 3554 if (interfaceElement != null) { |
| 3555 if (!visitedInterfaces.contains(interfaceElement)) { | 3555 if (!visitedInterfaces.contains(interfaceElement)) { |
| 3556 try { | 3556 try { |
| 3557 javaSetAdd(visitedInterfaces, interfaceElement); | 3557 javaSetAdd(visitedInterfaces, interfaceElement); |
| 3558 lookupMaps.add(computeInterfaceLookupMap(interfaceElement, visitedIn
terfaces)); | 3558 lookupMaps.add(computeInterfaceLookupMap(interfaceElement, visitedIn
terfaces)); |
| 3559 } finally { | 3559 } finally { |
| 3560 visitedInterfaces.remove(interfaceElement); | 3560 visitedInterfaces.remove(interfaceElement); |
| 3561 } | 3561 } |
| 3562 } else { | 3562 } else { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3581 if (!unionMap.containsKey(key)) { | 3581 if (!unionMap.containsKey(key)) { |
| 3582 Set<ExecutableElement> set = new Set<ExecutableElement>(); | 3582 Set<ExecutableElement> set = new Set<ExecutableElement>(); |
| 3583 javaSetAdd(set, entry.getValue()); | 3583 javaSetAdd(set, entry.getValue()); |
| 3584 unionMap[key] = set; | 3584 unionMap[key] = set; |
| 3585 } else { | 3585 } else { |
| 3586 javaSetAdd(unionMap[key], entry.getValue()); | 3586 javaSetAdd(unionMap[key], entry.getValue()); |
| 3587 } | 3587 } |
| 3588 } | 3588 } |
| 3589 } | 3589 } |
| 3590 if (superclassElement != null) { | 3590 if (superclassElement != null) { |
| 3591 List<MethodElement> methods2 = superclassElement.methods; | 3591 List<MethodElement> methods = superclassElement.methods; |
| 3592 for (MethodElement method in methods2) { | 3592 for (MethodElement method in methods) { |
| 3593 if (method.isAccessibleIn(_library) && !method.isStatic()) { | 3593 if (method.isAccessibleIn(_library) && !method.isStatic()) { |
| 3594 String key = method.name; | 3594 String key = method.name; |
| 3595 if (!unionMap.containsKey(key)) { | 3595 if (!unionMap.containsKey(key)) { |
| 3596 Set<ExecutableElement> set = new Set<ExecutableElement>(); | 3596 Set<ExecutableElement> set = new Set<ExecutableElement>(); |
| 3597 javaSetAdd(set, method); | 3597 javaSetAdd(set, method); |
| 3598 unionMap[key] = set; | 3598 unionMap[key] = set; |
| 3599 } else { | 3599 } else { |
| 3600 javaSetAdd(unionMap[key], method); | 3600 javaSetAdd(unionMap[key], method); |
| 3601 } | 3601 } |
| 3602 } | 3602 } |
| 3603 } | 3603 } |
| 3604 List<PropertyAccessorElement> accessors2 = superclassElement.accessors; | 3604 List<PropertyAccessorElement> accessors = superclassElement.accessors; |
| 3605 for (PropertyAccessorElement accessor in accessors2) { | 3605 for (PropertyAccessorElement accessor in accessors) { |
| 3606 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { | 3606 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { |
| 3607 String key = accessor.name; | 3607 String key = accessor.name; |
| 3608 if (!unionMap.containsKey(key)) { | 3608 if (!unionMap.containsKey(key)) { |
| 3609 Set<ExecutableElement> set = new Set<ExecutableElement>(); | 3609 Set<ExecutableElement> set = new Set<ExecutableElement>(); |
| 3610 javaSetAdd(set, accessor); | 3610 javaSetAdd(set, accessor); |
| 3611 unionMap[key] = set; | 3611 unionMap[key] = set; |
| 3612 } else { | 3612 } else { |
| 3613 javaSetAdd(unionMap[key], accessor); | 3613 javaSetAdd(unionMap[key], accessor); |
| 3614 } | 3614 } |
| 3615 } | 3615 } |
| 3616 } | 3616 } |
| 3617 } | 3617 } |
| 3618 for (InterfaceType interfaceType in interfaces2) { | 3618 for (InterfaceType interfaceType in interfaces) { |
| 3619 ClassElement interfaceElement = interfaceType.element; | 3619 ClassElement interfaceElement = interfaceType.element; |
| 3620 if (interfaceElement != null) { | 3620 if (interfaceElement != null) { |
| 3621 List<MethodElement> methods3 = interfaceElement.methods; | 3621 List<MethodElement> methods = interfaceElement.methods; |
| 3622 for (MethodElement method in methods3) { | 3622 for (MethodElement method in methods) { |
| 3623 if (method.isAccessibleIn(_library) && !method.isStatic()) { | 3623 if (method.isAccessibleIn(_library) && !method.isStatic()) { |
| 3624 String key = method.name; | 3624 String key = method.name; |
| 3625 if (!unionMap.containsKey(key)) { | 3625 if (!unionMap.containsKey(key)) { |
| 3626 Set<ExecutableElement> set = new Set<ExecutableElement>(); | 3626 Set<ExecutableElement> set = new Set<ExecutableElement>(); |
| 3627 javaSetAdd(set, method); | 3627 javaSetAdd(set, method); |
| 3628 unionMap[key] = set; | 3628 unionMap[key] = set; |
| 3629 } else { | 3629 } else { |
| 3630 javaSetAdd(unionMap[key], method); | 3630 javaSetAdd(unionMap[key], method); |
| 3631 } | 3631 } |
| 3632 } | 3632 } |
| 3633 } | 3633 } |
| 3634 List<PropertyAccessorElement> accessors3 = interfaceElement.accessors; | 3634 List<PropertyAccessorElement> accessors = interfaceElement.accessors; |
| 3635 for (PropertyAccessorElement accessor in accessors3) { | 3635 for (PropertyAccessorElement accessor in accessors) { |
| 3636 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { | 3636 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { |
| 3637 String key = accessor.name; | 3637 String key = accessor.name; |
| 3638 if (!unionMap.containsKey(key)) { | 3638 if (!unionMap.containsKey(key)) { |
| 3639 Set<ExecutableElement> set = new Set<ExecutableElement>(); | 3639 Set<ExecutableElement> set = new Set<ExecutableElement>(); |
| 3640 javaSetAdd(set, accessor); | 3640 javaSetAdd(set, accessor); |
| 3641 unionMap[key] = set; | 3641 unionMap[key] = set; |
| 3642 } else { | 3642 } else { |
| 3643 javaSetAdd(unionMap[key], accessor); | 3643 javaSetAdd(unionMap[key], accessor); |
| 3644 } | 3644 } |
| 3645 } | 3645 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3713 | 3713 |
| 3714 /** | 3714 /** |
| 3715 * Given some {@link ClassElement}, this method finds and returns the {@link E
xecutableElement} of | 3715 * Given some {@link ClassElement}, this method finds and returns the {@link E
xecutableElement} of |
| 3716 * the passed name in the class element. Static members, members in super type
s and members not | 3716 * the passed name in the class element. Static members, members in super type
s and members not |
| 3717 * accessible from the current library are not considered. | 3717 * accessible from the current library are not considered. |
| 3718 * @param classElt the class element to query | 3718 * @param classElt the class element to query |
| 3719 * @param memberName the name of the member to lookup in the class | 3719 * @param memberName the name of the member to lookup in the class |
| 3720 * @return the found {@link ExecutableElement}, or {@code null} if no such mem
ber was found | 3720 * @return the found {@link ExecutableElement}, or {@code null} if no such mem
ber was found |
| 3721 */ | 3721 */ |
| 3722 ExecutableElement lookupMemberInClass(ClassElement classElt, String memberName
) { | 3722 ExecutableElement lookupMemberInClass(ClassElement classElt, String memberName
) { |
| 3723 List<MethodElement> methods2 = classElt.methods; | 3723 List<MethodElement> methods = classElt.methods; |
| 3724 for (MethodElement method in methods2) { | 3724 for (MethodElement method in methods) { |
| 3725 if (memberName == method.name && method.isAccessibleIn(_library) && !metho
d.isStatic()) { | 3725 if (memberName == method.name && method.isAccessibleIn(_library) && !metho
d.isStatic()) { |
| 3726 return method; | 3726 return method; |
| 3727 } | 3727 } |
| 3728 } | 3728 } |
| 3729 List<PropertyAccessorElement> accessors2 = classElt.accessors; | 3729 List<PropertyAccessorElement> accessors = classElt.accessors; |
| 3730 for (PropertyAccessorElement accessor in accessors2) { | 3730 for (PropertyAccessorElement accessor in accessors) { |
| 3731 if (memberName == accessor.name && accessor.isAccessibleIn(_library) && !a
ccessor.isStatic()) { | 3731 if (memberName == accessor.name && accessor.isAccessibleIn(_library) && !a
ccessor.isStatic()) { |
| 3732 return accessor; | 3732 return accessor; |
| 3733 } | 3733 } |
| 3734 } | 3734 } |
| 3735 return null; | 3735 return null; |
| 3736 } | 3736 } |
| 3737 | 3737 |
| 3738 /** | 3738 /** |
| 3739 * Record the passed map with the set of all members (methods, getters and set
ters) in the class | 3739 * Record the passed map with the set of all members (methods, getters and set
ters) in the class |
| 3740 * into the passed map. | 3740 * into the passed map. |
| 3741 * @param map some non-{@code null} | 3741 * @param map some non-{@code null} |
| 3742 * @param classElt the class element that will be recorded into the passed map | 3742 * @param classElt the class element that will be recorded into the passed map |
| 3743 */ | 3743 */ |
| 3744 void recordMapWithClassMembers(Map<String, ExecutableElement> map, ClassElemen
t classElt) { | 3744 void recordMapWithClassMembers(Map<String, ExecutableElement> map, ClassElemen
t classElt) { |
| 3745 List<MethodElement> methods2 = classElt.methods; | 3745 List<MethodElement> methods = classElt.methods; |
| 3746 for (MethodElement method in methods2) { | 3746 for (MethodElement method in methods) { |
| 3747 if (method.isAccessibleIn(_library) && !method.isStatic()) { | 3747 if (method.isAccessibleIn(_library) && !method.isStatic()) { |
| 3748 map[method.name] = method; | 3748 map[method.name] = method; |
| 3749 } | 3749 } |
| 3750 } | 3750 } |
| 3751 List<PropertyAccessorElement> accessors2 = classElt.accessors; | 3751 List<PropertyAccessorElement> accessors = classElt.accessors; |
| 3752 for (PropertyAccessorElement accessor in accessors2) { | 3752 for (PropertyAccessorElement accessor in accessors) { |
| 3753 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { | 3753 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { |
| 3754 map[accessor.name] = accessor; | 3754 map[accessor.name] = accessor; |
| 3755 } | 3755 } |
| 3756 } | 3756 } |
| 3757 } | 3757 } |
| 3758 | 3758 |
| 3759 /** | 3759 /** |
| 3760 * This method is used to report errors on when they are found computing inher
itance information. | 3760 * This method is used to report errors on when they are found computing inher
itance information. |
| 3761 * See {@link ErrorVerifier#checkForInconsistentMethodInheritance()} to see wh
ere these generated | 3761 * See {@link ErrorVerifier#checkForInconsistentMethodInheritance()} to see wh
ere these generated |
| 3762 * error codes are reported back into the analysis engine. | 3762 * error codes are reported back into the analysis engine. |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4098 } | 4098 } |
| 4099 | 4099 |
| 4100 /** | 4100 /** |
| 4101 * Build the library element for the given library. | 4101 * Build the library element for the given library. |
| 4102 * @param library the library for which an element model is to be built | 4102 * @param library the library for which an element model is to be built |
| 4103 * @return the library element that was built | 4103 * @return the library element that was built |
| 4104 * @throws AnalysisException if the analysis could not be performed | 4104 * @throws AnalysisException if the analysis could not be performed |
| 4105 */ | 4105 */ |
| 4106 LibraryElementImpl buildLibrary(Library library) { | 4106 LibraryElementImpl buildLibrary(Library library) { |
| 4107 CompilationUnitBuilder builder = new CompilationUnitBuilder(); | 4107 CompilationUnitBuilder builder = new CompilationUnitBuilder(); |
| 4108 Source librarySource2 = library.librarySource; | 4108 Source librarySource = library.librarySource; |
| 4109 CompilationUnit definingCompilationUnit2 = library.definingCompilationUnit; | 4109 CompilationUnit definingCompilationUnit = library.definingCompilationUnit; |
| 4110 CompilationUnitElementImpl definingCompilationUnitElement = builder.buildCom
pilationUnit(librarySource2, definingCompilationUnit2); | 4110 CompilationUnitElementImpl definingCompilationUnitElement = builder.buildCom
pilationUnit(librarySource, definingCompilationUnit); |
| 4111 NodeList<Directive> directives2 = definingCompilationUnit2.directives; | 4111 NodeList<Directive> directives = definingCompilationUnit.directives; |
| 4112 LibraryIdentifier libraryNameNode = null; | 4112 LibraryIdentifier libraryNameNode = null; |
| 4113 bool hasPartDirective = false; | 4113 bool hasPartDirective = false; |
| 4114 FunctionElement entryPoint = findEntryPoint(definingCompilationUnitElement); | 4114 FunctionElement entryPoint = findEntryPoint(definingCompilationUnitElement); |
| 4115 List<Directive> directivesToResolve = new List<Directive>(); | 4115 List<Directive> directivesToResolve = new List<Directive>(); |
| 4116 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat
ionUnitElementImpl>(); | 4116 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat
ionUnitElementImpl>(); |
| 4117 for (Directive directive in directives2) { | 4117 for (Directive directive in directives) { |
| 4118 if (directive is LibraryDirective) { | 4118 if (directive is LibraryDirective) { |
| 4119 if (libraryNameNode == null) { | 4119 if (libraryNameNode == null) { |
| 4120 libraryNameNode = ((directive as LibraryDirective)).name; | 4120 libraryNameNode = ((directive as LibraryDirective)).name; |
| 4121 directivesToResolve.add(directive); | 4121 directivesToResolve.add(directive); |
| 4122 } | 4122 } |
| 4123 } else if (directive is PartDirective) { | 4123 } else if (directive is PartDirective) { |
| 4124 PartDirective partDirective = directive as PartDirective; | 4124 PartDirective partDirective = directive as PartDirective; |
| 4125 StringLiteral partUri = partDirective.uri; | 4125 StringLiteral partUri = partDirective.uri; |
| 4126 Source partSource = library.getSource(partDirective); | 4126 Source partSource = library.getSource(partDirective); |
| 4127 if (partSource != null && partSource.exists()) { | 4127 if (partSource != null && partSource.exists()) { |
| 4128 hasPartDirective = true; | 4128 hasPartDirective = true; |
| 4129 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou
rce, library.getAST(partSource)); | 4129 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou
rce, library.getAST(partSource)); |
| 4130 part.uri = library.getUri(partDirective); | 4130 part.uri = library.getUri(partDirective); |
| 4131 String partLibraryName = getPartLibraryName(library, partSource, direc
tivesToResolve); | 4131 String partLibraryName = getPartLibraryName(library, partSource, direc
tivesToResolve); |
| 4132 if (partLibraryName == null) { | 4132 if (partLibraryName == null) { |
| 4133 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSour
ce()])); | 4133 _errorListener.onError(new AnalysisError.con2(librarySource, partUri
.offset, partUri.length, CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSourc
e()])); |
| 4134 } else if (libraryNameNode == null) { | 4134 } else if (libraryNameNode == null) { |
| 4135 } else if (libraryNameNode.name != partLibraryName) { | 4135 } else if (libraryNameNode.name != partLibraryName) { |
| 4136 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [libraryN
ameNode.name, partLibraryName])); | 4136 _errorListener.onError(new AnalysisError.con2(librarySource, partUri
.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [libraryNa
meNode.name, partLibraryName])); |
| 4137 } | 4137 } |
| 4138 if (entryPoint == null) { | 4138 if (entryPoint == null) { |
| 4139 entryPoint = findEntryPoint(part); | 4139 entryPoint = findEntryPoint(part); |
| 4140 } | 4140 } |
| 4141 directive.element = part; | 4141 directive.element = part; |
| 4142 sourcedCompilationUnits.add(part); | 4142 sourcedCompilationUnits.add(part); |
| 4143 } | 4143 } |
| 4144 } | 4144 } |
| 4145 } | 4145 } |
| 4146 if (hasPartDirective && libraryNameNode == null) { | 4146 if (hasPartDirective && libraryNameNode == null) { |
| 4147 _errorListener.onError(new AnalysisError.con1(librarySource2, ResolverErro
rCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART, [])); | 4147 _errorListener.onError(new AnalysisError.con1(librarySource, ResolverError
Code.MISSING_LIBRARY_DIRECTIVE_WITH_PART, [])); |
| 4148 } | 4148 } |
| 4149 LibraryElementImpl libraryElement = new LibraryElementImpl(_analysisContext,
libraryNameNode); | 4149 LibraryElementImpl libraryElement = new LibraryElementImpl(_analysisContext,
libraryNameNode); |
| 4150 libraryElement.definingCompilationUnit = definingCompilationUnitElement; | 4150 libraryElement.definingCompilationUnit = definingCompilationUnitElement; |
| 4151 if (entryPoint != null) { | 4151 if (entryPoint != null) { |
| 4152 libraryElement.entryPoint = entryPoint; | 4152 libraryElement.entryPoint = entryPoint; |
| 4153 } | 4153 } |
| 4154 int sourcedUnitCount = sourcedCompilationUnits.length; | 4154 int sourcedUnitCount = sourcedCompilationUnits.length; |
| 4155 libraryElement.parts = new List.from(sourcedCompilationUnits); | 4155 libraryElement.parts = new List.from(sourcedCompilationUnits); |
| 4156 for (Directive directive in directivesToResolve) { | 4156 for (Directive directive in directivesToResolve) { |
| 4157 directive.element = libraryElement; | 4157 directive.element = libraryElement; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4206 * @param directivesToResolve a list of directives that should be resolved to
the library being | 4206 * @param directivesToResolve a list of directives that should be resolved to
the library being |
| 4207 * built | 4207 * built |
| 4208 * @return the name of the library that the given part is declared to be a par
t of | 4208 * @return the name of the library that the given part is declared to be a par
t of |
| 4209 */ | 4209 */ |
| 4210 String getPartLibraryName(Library library, Source partSource, List<Directive>
directivesToResolve) { | 4210 String getPartLibraryName(Library library, Source partSource, List<Directive>
directivesToResolve) { |
| 4211 try { | 4211 try { |
| 4212 CompilationUnit partUnit = library.getAST(partSource); | 4212 CompilationUnit partUnit = library.getAST(partSource); |
| 4213 for (Directive directive in partUnit.directives) { | 4213 for (Directive directive in partUnit.directives) { |
| 4214 if (directive is PartOfDirective) { | 4214 if (directive is PartOfDirective) { |
| 4215 directivesToResolve.add(directive); | 4215 directivesToResolve.add(directive); |
| 4216 LibraryIdentifier libraryName2 = ((directive as PartOfDirective)).libr
aryName; | 4216 LibraryIdentifier libraryName = ((directive as PartOfDirective)).libra
ryName; |
| 4217 if (libraryName2 != null) { | 4217 if (libraryName != null) { |
| 4218 return libraryName2.name; | 4218 return libraryName.name; |
| 4219 } | 4219 } |
| 4220 } | 4220 } |
| 4221 } | 4221 } |
| 4222 } on AnalysisException catch (exception) { | 4222 } on AnalysisException catch (exception) { |
| 4223 } | 4223 } |
| 4224 return null; | 4224 return null; |
| 4225 } | 4225 } |
| 4226 | 4226 |
| 4227 /** | 4227 /** |
| 4228 * Look through all of the compilation units defined for the given library, lo
oking for getters | 4228 * Look through all of the compilation units defined for the given library, lo
oking for getters |
| 4229 * and setters that are defined in different compilation units but that have t
he same names. If | 4229 * and setters that are defined in different compilation units but that have t
he same names. If |
| 4230 * any are found, make sure that they have the same variable element. | 4230 * any are found, make sure that they have the same variable element. |
| 4231 * @param libraryElement the library defining the compilation units to be proc
essed | 4231 * @param libraryElement the library defining the compilation units to be proc
essed |
| 4232 */ | 4232 */ |
| 4233 void patchTopLevelAccessors(LibraryElementImpl libraryElement) { | 4233 void patchTopLevelAccessors(LibraryElementImpl libraryElement) { |
| 4234 Map<String, PropertyAccessorElement> getters = new Map<String, PropertyAcces
sorElement>(); | 4234 Map<String, PropertyAccessorElement> getters = new Map<String, PropertyAcces
sorElement>(); |
| 4235 List<PropertyAccessorElement> setters = new List<PropertyAccessorElement>(); | 4235 List<PropertyAccessorElement> setters = new List<PropertyAccessorElement>(); |
| 4236 collectAccessors(getters, setters, libraryElement.definingCompilationUnit); | 4236 collectAccessors(getters, setters, libraryElement.definingCompilationUnit); |
| 4237 for (CompilationUnitElement unit in libraryElement.parts) { | 4237 for (CompilationUnitElement unit in libraryElement.parts) { |
| 4238 collectAccessors(getters, setters, unit); | 4238 collectAccessors(getters, setters, unit); |
| 4239 } | 4239 } |
| 4240 for (PropertyAccessorElement setter in setters) { | 4240 for (PropertyAccessorElement setter in setters) { |
| 4241 PropertyAccessorElement getter = getters[setter.displayName]; | 4241 PropertyAccessorElement getter = getters[setter.displayName]; |
| 4242 if (getter != null) { | 4242 if (getter != null) { |
| 4243 PropertyInducingElementImpl variable2 = getter.variable as PropertyInduc
ingElementImpl; | 4243 PropertyInducingElementImpl variable = getter.variable as PropertyInduci
ngElementImpl; |
| 4244 variable2.setter = setter; | 4244 variable.setter = setter; |
| 4245 ((setter as PropertyAccessorElementImpl)).variable = variable2; | 4245 ((setter as PropertyAccessorElementImpl)).variable = variable; |
| 4246 } | 4246 } |
| 4247 } | 4247 } |
| 4248 } | 4248 } |
| 4249 } | 4249 } |
| 4250 /** | 4250 /** |
| 4251 * Instances of the class {@code LibraryResolver} are used to resolve one or mor
e mutually dependent | 4251 * Instances of the class {@code LibraryResolver} are used to resolve one or mor
e mutually dependent |
| 4252 * libraries within a single context. | 4252 * libraries within a single context. |
| 4253 * @coverage dart.engine.resolver | 4253 * @coverage dart.engine.resolver |
| 4254 */ | 4254 */ |
| 4255 class LibraryResolver { | 4255 class LibraryResolver { |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4541 if (exportedLibrary != null) { | 4541 if (exportedLibrary != null) { |
| 4542 LibraryElement exportedLibraryElement = exportedLibrary.libraryEleme
nt; | 4542 LibraryElement exportedLibraryElement = exportedLibrary.libraryEleme
nt; |
| 4543 if (exportedLibraryElement != null) { | 4543 if (exportedLibraryElement != null) { |
| 4544 exportElement.exportedLibrary = exportedLibraryElement; | 4544 exportElement.exportedLibrary = exportedLibraryElement; |
| 4545 } | 4545 } |
| 4546 directive.element = exportElement; | 4546 directive.element = exportElement; |
| 4547 exports.add(exportElement); | 4547 exports.add(exportElement); |
| 4548 } | 4548 } |
| 4549 } | 4549 } |
| 4550 } | 4550 } |
| 4551 Source librarySource2 = library.librarySource; | 4551 Source librarySource = library.librarySource; |
| 4552 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource2
) { | 4552 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource)
{ |
| 4553 ImportElementImpl importElement = new ImportElementImpl(); | 4553 ImportElementImpl importElement = new ImportElementImpl(); |
| 4554 importElement.importedLibrary = _coreLibrary.libraryElement; | 4554 importElement.importedLibrary = _coreLibrary.libraryElement; |
| 4555 importElement.synthetic = true; | 4555 importElement.synthetic = true; |
| 4556 imports.add(importElement); | 4556 imports.add(importElement); |
| 4557 } | 4557 } |
| 4558 LibraryElementImpl libraryElement2 = library.libraryElement; | 4558 LibraryElementImpl libraryElement = library.libraryElement; |
| 4559 libraryElement2.imports = new List.from(imports); | 4559 libraryElement.imports = new List.from(imports); |
| 4560 libraryElement2.exports = new List.from(exports); | 4560 libraryElement.exports = new List.from(exports); |
| 4561 } | 4561 } |
| 4562 } | 4562 } |
| 4563 | 4563 |
| 4564 /** | 4564 /** |
| 4565 * Build element models for all of the libraries in the current cycle. | 4565 * Build element models for all of the libraries in the current cycle. |
| 4566 * @throws AnalysisException if any of the element models cannot be built | 4566 * @throws AnalysisException if any of the element models cannot be built |
| 4567 */ | 4567 */ |
| 4568 void buildElementModels() { | 4568 void buildElementModels() { |
| 4569 for (Library library in _librariesInCycles) { | 4569 for (Library library in _librariesInCycles) { |
| 4570 LibraryElementBuilder builder = new LibraryElementBuilder(this); | 4570 LibraryElementBuilder builder = new LibraryElementBuilder(this); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4730 _libraryMap[librarySource] = library; | 4730 _libraryMap[librarySource] = library; |
| 4731 return library; | 4731 return library; |
| 4732 } | 4732 } |
| 4733 | 4733 |
| 4734 /** | 4734 /** |
| 4735 * Return {@code true} if and only if the passed {@link CompilationUnit} has a
part-of directive. | 4735 * Return {@code true} if and only if the passed {@link CompilationUnit} has a
part-of directive. |
| 4736 * @param node the {@link CompilationUnit} to test | 4736 * @param node the {@link CompilationUnit} to test |
| 4737 * @return {@code true} if and only if the passed {@link CompilationUnit} has
a part-of directive | 4737 * @return {@code true} if and only if the passed {@link CompilationUnit} has
a part-of directive |
| 4738 */ | 4738 */ |
| 4739 bool doesCompilationUnitHavePartOfDirective(CompilationUnit node) { | 4739 bool doesCompilationUnitHavePartOfDirective(CompilationUnit node) { |
| 4740 NodeList<Directive> directives2 = node.directives; | 4740 NodeList<Directive> directives = node.directives; |
| 4741 for (Directive directive in directives2) { | 4741 for (Directive directive in directives) { |
| 4742 if (directive is PartOfDirective) { | 4742 if (directive is PartOfDirective) { |
| 4743 return true; | 4743 return true; |
| 4744 } | 4744 } |
| 4745 } | 4745 } |
| 4746 return false; | 4746 return false; |
| 4747 } | 4747 } |
| 4748 | 4748 |
| 4749 /** | 4749 /** |
| 4750 * Return an array containing the lexical identifiers associated with the node
s in the given list. | 4750 * Return an array containing the lexical identifiers associated with the node
s in the given list. |
| 4751 * @param names the AST nodes representing the identifiers | 4751 * @param names the AST nodes representing the identifiers |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4911 } | 4911 } |
| 4912 return null; | 4912 return null; |
| 4913 } | 4913 } |
| 4914 Object visitAssertStatement(AssertStatement node) { | 4914 Object visitAssertStatement(AssertStatement node) { |
| 4915 super.visitAssertStatement(node); | 4915 super.visitAssertStatement(node); |
| 4916 propagateTrueState(node.condition); | 4916 propagateTrueState(node.condition); |
| 4917 return null; | 4917 return null; |
| 4918 } | 4918 } |
| 4919 Object visitBinaryExpression(BinaryExpression node) { | 4919 Object visitBinaryExpression(BinaryExpression node) { |
| 4920 sc.TokenType operatorType = node.operator.type; | 4920 sc.TokenType operatorType = node.operator.type; |
| 4921 Expression leftOperand2 = node.leftOperand; | 4921 Expression leftOperand = node.leftOperand; |
| 4922 Expression rightOperand2 = node.rightOperand; | 4922 Expression rightOperand = node.rightOperand; |
| 4923 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { | 4923 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { |
| 4924 safelyVisit(leftOperand2); | 4924 safelyVisit(leftOperand); |
| 4925 if (rightOperand2 != null) { | 4925 if (rightOperand != null) { |
| 4926 try { | 4926 try { |
| 4927 _overrideManager.enterScope(); | 4927 _overrideManager.enterScope(); |
| 4928 propagateTrueState(leftOperand2); | 4928 propagateTrueState(leftOperand); |
| 4929 rightOperand2.accept(this); | 4929 rightOperand.accept(this); |
| 4930 } finally { | 4930 } finally { |
| 4931 _overrideManager.exitScope(); | 4931 _overrideManager.exitScope(); |
| 4932 } | 4932 } |
| 4933 } | 4933 } |
| 4934 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) { | 4934 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) { |
| 4935 safelyVisit(leftOperand2); | 4935 safelyVisit(leftOperand); |
| 4936 if (rightOperand2 != null) { | 4936 if (rightOperand != null) { |
| 4937 try { | 4937 try { |
| 4938 _overrideManager.enterScope(); | 4938 _overrideManager.enterScope(); |
| 4939 propagateFalseState(leftOperand2); | 4939 propagateFalseState(leftOperand); |
| 4940 rightOperand2.accept(this); | 4940 rightOperand.accept(this); |
| 4941 } finally { | 4941 } finally { |
| 4942 _overrideManager.exitScope(); | 4942 _overrideManager.exitScope(); |
| 4943 } | 4943 } |
| 4944 } | 4944 } |
| 4945 } else { | 4945 } else { |
| 4946 safelyVisit(leftOperand2); | 4946 safelyVisit(leftOperand); |
| 4947 safelyVisit(rightOperand2); | 4947 safelyVisit(rightOperand); |
| 4948 } | 4948 } |
| 4949 node.accept(_elementResolver); | 4949 node.accept(_elementResolver); |
| 4950 node.accept(_typeAnalyzer); | 4950 node.accept(_typeAnalyzer); |
| 4951 return null; | 4951 return null; |
| 4952 } | 4952 } |
| 4953 Object visitBreakStatement(BreakStatement node) { | 4953 Object visitBreakStatement(BreakStatement node) { |
| 4954 node.accept(_elementResolver); | 4954 node.accept(_elementResolver); |
| 4955 node.accept(_typeAnalyzer); | 4955 node.accept(_typeAnalyzer); |
| 4956 return null; | 4956 return null; |
| 4957 } | 4957 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4990 declaration.accept(this); | 4990 declaration.accept(this); |
| 4991 } | 4991 } |
| 4992 } finally { | 4992 } finally { |
| 4993 _overrideManager.exitScope(); | 4993 _overrideManager.exitScope(); |
| 4994 } | 4994 } |
| 4995 node.accept(_elementResolver); | 4995 node.accept(_elementResolver); |
| 4996 node.accept(_typeAnalyzer); | 4996 node.accept(_typeAnalyzer); |
| 4997 return null; | 4997 return null; |
| 4998 } | 4998 } |
| 4999 Object visitConditionalExpression(ConditionalExpression node) { | 4999 Object visitConditionalExpression(ConditionalExpression node) { |
| 5000 Expression condition2 = node.condition; | 5000 Expression condition = node.condition; |
| 5001 safelyVisit(condition2); | 5001 safelyVisit(condition); |
| 5002 Expression thenExpression2 = node.thenExpression; | 5002 Expression thenExpression = node.thenExpression; |
| 5003 if (thenExpression2 != null) { | 5003 if (thenExpression != null) { |
| 5004 try { | 5004 try { |
| 5005 _overrideManager.enterScope(); | 5005 _overrideManager.enterScope(); |
| 5006 propagateTrueState(condition2); | 5006 propagateTrueState(condition); |
| 5007 thenExpression2.accept(this); | 5007 thenExpression.accept(this); |
| 5008 } finally { | 5008 } finally { |
| 5009 _overrideManager.exitScope(); | 5009 _overrideManager.exitScope(); |
| 5010 } | 5010 } |
| 5011 } | 5011 } |
| 5012 Expression elseExpression2 = node.elseExpression; | 5012 Expression elseExpression = node.elseExpression; |
| 5013 if (elseExpression2 != null) { | 5013 if (elseExpression != null) { |
| 5014 try { | 5014 try { |
| 5015 _overrideManager.enterScope(); | 5015 _overrideManager.enterScope(); |
| 5016 propagateFalseState(condition2); | 5016 propagateFalseState(condition); |
| 5017 elseExpression2.accept(this); | 5017 elseExpression.accept(this); |
| 5018 } finally { | 5018 } finally { |
| 5019 _overrideManager.exitScope(); | 5019 _overrideManager.exitScope(); |
| 5020 } | 5020 } |
| 5021 } | 5021 } |
| 5022 node.accept(_elementResolver); | 5022 node.accept(_elementResolver); |
| 5023 node.accept(_typeAnalyzer); | 5023 node.accept(_typeAnalyzer); |
| 5024 bool thenIsAbrupt = isAbruptTermination(thenExpression2); | 5024 bool thenIsAbrupt = isAbruptTermination(thenExpression); |
| 5025 bool elseIsAbrupt = isAbruptTermination(elseExpression2); | 5025 bool elseIsAbrupt = isAbruptTermination(elseExpression); |
| 5026 if (elseIsAbrupt && !thenIsAbrupt) { | 5026 if (elseIsAbrupt && !thenIsAbrupt) { |
| 5027 propagateTrueState(condition2); | 5027 propagateTrueState(condition); |
| 5028 propagateState(thenExpression2); | 5028 propagateState(thenExpression); |
| 5029 } else if (thenIsAbrupt && !elseIsAbrupt) { | 5029 } else if (thenIsAbrupt && !elseIsAbrupt) { |
| 5030 propagateFalseState(condition2); | 5030 propagateFalseState(condition); |
| 5031 propagateState(elseExpression2); | 5031 propagateState(elseExpression); |
| 5032 } | 5032 } |
| 5033 return null; | 5033 return null; |
| 5034 } | 5034 } |
| 5035 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 5035 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 5036 ExecutableElement outerFunction = _enclosingFunction; | 5036 ExecutableElement outerFunction = _enclosingFunction; |
| 5037 try { | 5037 try { |
| 5038 _enclosingFunction = node.element; | 5038 _enclosingFunction = node.element; |
| 5039 super.visitConstructorDeclaration(node); | 5039 super.visitConstructorDeclaration(node); |
| 5040 } finally { | 5040 } finally { |
| 5041 _enclosingFunction = outerFunction; | 5041 _enclosingFunction = outerFunction; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5123 _overrideManager.enterScope(); | 5123 _overrideManager.enterScope(); |
| 5124 super.visitFunctionExpression(node); | 5124 super.visitFunctionExpression(node); |
| 5125 } finally { | 5125 } finally { |
| 5126 _overrideManager.exitScope(); | 5126 _overrideManager.exitScope(); |
| 5127 _enclosingFunction = outerFunction; | 5127 _enclosingFunction = outerFunction; |
| 5128 } | 5128 } |
| 5129 return null; | 5129 return null; |
| 5130 } | 5130 } |
| 5131 Object visitHideCombinator(HideCombinator node) => null; | 5131 Object visitHideCombinator(HideCombinator node) => null; |
| 5132 Object visitIfStatement(IfStatement node) { | 5132 Object visitIfStatement(IfStatement node) { |
| 5133 Expression condition2 = node.condition; | 5133 Expression condition = node.condition; |
| 5134 safelyVisit(condition2); | 5134 safelyVisit(condition); |
| 5135 Map<Element, Type2> thenOverrides = null; | 5135 Map<Element, Type2> thenOverrides = null; |
| 5136 Statement thenStatement2 = node.thenStatement; | 5136 Statement thenStatement = node.thenStatement; |
| 5137 if (thenStatement2 != null) { | 5137 if (thenStatement != null) { |
| 5138 try { | 5138 try { |
| 5139 _overrideManager.enterScope(); | 5139 _overrideManager.enterScope(); |
| 5140 propagateTrueState(condition2); | 5140 propagateTrueState(condition); |
| 5141 thenStatement2.accept(this); | 5141 thenStatement.accept(this); |
| 5142 } finally { | 5142 } finally { |
| 5143 thenOverrides = _overrideManager.captureLocalOverrides(); | 5143 thenOverrides = _overrideManager.captureLocalOverrides(); |
| 5144 _overrideManager.exitScope(); | 5144 _overrideManager.exitScope(); |
| 5145 } | 5145 } |
| 5146 } | 5146 } |
| 5147 Map<Element, Type2> elseOverrides = null; | 5147 Map<Element, Type2> elseOverrides = null; |
| 5148 Statement elseStatement2 = node.elseStatement; | 5148 Statement elseStatement = node.elseStatement; |
| 5149 if (elseStatement2 != null) { | 5149 if (elseStatement != null) { |
| 5150 try { | 5150 try { |
| 5151 _overrideManager.enterScope(); | 5151 _overrideManager.enterScope(); |
| 5152 propagateFalseState(condition2); | 5152 propagateFalseState(condition); |
| 5153 elseStatement2.accept(this); | 5153 elseStatement.accept(this); |
| 5154 } finally { | 5154 } finally { |
| 5155 elseOverrides = _overrideManager.captureLocalOverrides(); | 5155 elseOverrides = _overrideManager.captureLocalOverrides(); |
| 5156 _overrideManager.exitScope(); | 5156 _overrideManager.exitScope(); |
| 5157 } | 5157 } |
| 5158 } | 5158 } |
| 5159 node.accept(_elementResolver); | 5159 node.accept(_elementResolver); |
| 5160 node.accept(_typeAnalyzer); | 5160 node.accept(_typeAnalyzer); |
| 5161 bool thenIsAbrupt = isAbruptTermination2(thenStatement2); | 5161 bool thenIsAbrupt = isAbruptTermination2(thenStatement); |
| 5162 bool elseIsAbrupt = isAbruptTermination2(elseStatement2); | 5162 bool elseIsAbrupt = isAbruptTermination2(elseStatement); |
| 5163 if (elseIsAbrupt && !thenIsAbrupt) { | 5163 if (elseIsAbrupt && !thenIsAbrupt) { |
| 5164 propagateTrueState(condition2); | 5164 propagateTrueState(condition); |
| 5165 if (thenOverrides != null) { | 5165 if (thenOverrides != null) { |
| 5166 _overrideManager.applyOverrides(thenOverrides); | 5166 _overrideManager.applyOverrides(thenOverrides); |
| 5167 } | 5167 } |
| 5168 } else if (thenIsAbrupt && !elseIsAbrupt) { | 5168 } else if (thenIsAbrupt && !elseIsAbrupt) { |
| 5169 propagateFalseState(condition2); | 5169 propagateFalseState(condition); |
| 5170 if (elseOverrides != null) { | 5170 if (elseOverrides != null) { |
| 5171 _overrideManager.applyOverrides(elseOverrides); | 5171 _overrideManager.applyOverrides(elseOverrides); |
| 5172 } | 5172 } |
| 5173 } | 5173 } |
| 5174 return null; | 5174 return null; |
| 5175 } | 5175 } |
| 5176 Object visitLabel(Label node) => null; | 5176 Object visitLabel(Label node) => null; |
| 5177 Object visitLibraryIdentifier(LibraryIdentifier node) => null; | 5177 Object visitLibraryIdentifier(LibraryIdentifier node) => null; |
| 5178 Object visitMethodDeclaration(MethodDeclaration node) { | 5178 Object visitMethodDeclaration(MethodDeclaration node) { |
| 5179 ExecutableElement outerFunction = _enclosingFunction; | 5179 ExecutableElement outerFunction = _enclosingFunction; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5247 super.visitTopLevelVariableDeclaration(node); | 5247 super.visitTopLevelVariableDeclaration(node); |
| 5248 } finally { | 5248 } finally { |
| 5249 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.var
iables); | 5249 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.var
iables); |
| 5250 _overrideManager.exitScope(); | 5250 _overrideManager.exitScope(); |
| 5251 _overrideManager.applyOverrides(overrides); | 5251 _overrideManager.applyOverrides(overrides); |
| 5252 } | 5252 } |
| 5253 return null; | 5253 return null; |
| 5254 } | 5254 } |
| 5255 Object visitTypeName(TypeName node) => null; | 5255 Object visitTypeName(TypeName node) => null; |
| 5256 Object visitWhileStatement(WhileStatement node) { | 5256 Object visitWhileStatement(WhileStatement node) { |
| 5257 Expression condition2 = node.condition; | 5257 Expression condition = node.condition; |
| 5258 safelyVisit(condition2); | 5258 safelyVisit(condition); |
| 5259 Statement body2 = node.body; | 5259 Statement body = node.body; |
| 5260 if (body2 != null) { | 5260 if (body != null) { |
| 5261 try { | 5261 try { |
| 5262 _overrideManager.enterScope(); | 5262 _overrideManager.enterScope(); |
| 5263 propagateTrueState(condition2); | 5263 propagateTrueState(condition); |
| 5264 body2.accept(this); | 5264 body.accept(this); |
| 5265 } finally { | 5265 } finally { |
| 5266 _overrideManager.exitScope(); | 5266 _overrideManager.exitScope(); |
| 5267 } | 5267 } |
| 5268 } | 5268 } |
| 5269 node.accept(_elementResolver); | 5269 node.accept(_elementResolver); |
| 5270 node.accept(_typeAnalyzer); | 5270 node.accept(_typeAnalyzer); |
| 5271 return null; | 5271 return null; |
| 5272 } | 5272 } |
| 5273 | 5273 |
| 5274 /** | 5274 /** |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5321 if (!variable.isConst() && !variable.isFinal()) { | 5321 if (!variable.isConst() && !variable.isFinal()) { |
| 5322 return; | 5322 return; |
| 5323 } | 5323 } |
| 5324 } | 5324 } |
| 5325 Type2 currentType = getBestType(element); | 5325 Type2 currentType = getBestType(element); |
| 5326 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { | 5326 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { |
| 5327 _overrideManager.setType(element, potentialType); | 5327 _overrideManager.setType(element, potentialType); |
| 5328 } | 5328 } |
| 5329 } | 5329 } |
| 5330 void visitForEachStatementInScope(ForEachStatement node) { | 5330 void visitForEachStatementInScope(ForEachStatement node) { |
| 5331 Expression iterator2 = node.iterator; | 5331 Expression iterator = node.iterator; |
| 5332 safelyVisit(iterator2); | 5332 safelyVisit(iterator); |
| 5333 DeclaredIdentifier loopVariable2 = node.loopVariable; | 5333 DeclaredIdentifier loopVariable = node.loopVariable; |
| 5334 safelyVisit(loopVariable2); | 5334 safelyVisit(loopVariable); |
| 5335 Statement body2 = node.body; | 5335 Statement body = node.body; |
| 5336 if (body2 != null) { | 5336 if (body != null) { |
| 5337 try { | 5337 try { |
| 5338 _overrideManager.enterScope(); | 5338 _overrideManager.enterScope(); |
| 5339 if (loopVariable2 != null && iterator2 != null) { | 5339 if (loopVariable != null && iterator != null) { |
| 5340 LocalVariableElement loopElement = loopVariable2.element; | 5340 LocalVariableElement loopElement = loopVariable.element; |
| 5341 if (loopElement != null) { | 5341 if (loopElement != null) { |
| 5342 override(loopElement, getIteratorElementType(iterator2)); | 5342 override(loopElement, getIteratorElementType(iterator)); |
| 5343 } | 5343 } |
| 5344 } | 5344 } |
| 5345 body2.accept(this); | 5345 body.accept(this); |
| 5346 } finally { | 5346 } finally { |
| 5347 _overrideManager.exitScope(); | 5347 _overrideManager.exitScope(); |
| 5348 } | 5348 } |
| 5349 } | 5349 } |
| 5350 node.accept(_elementResolver); | 5350 node.accept(_elementResolver); |
| 5351 node.accept(_typeAnalyzer); | 5351 node.accept(_typeAnalyzer); |
| 5352 } | 5352 } |
| 5353 void visitForStatementInScope(ForStatement node) { | 5353 void visitForStatementInScope(ForStatement node) { |
| 5354 safelyVisit(node.variables); | 5354 safelyVisit(node.variables); |
| 5355 safelyVisit(node.initialization); | 5355 safelyVisit(node.initialization); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5426 * following the given statement will not be reached). | 5426 * following the given statement will not be reached). |
| 5427 * @param statement the statement being tested | 5427 * @param statement the statement being tested |
| 5428 * @return {@code true} if the given statement terminates abruptly | 5428 * @return {@code true} if the given statement terminates abruptly |
| 5429 */ | 5429 */ |
| 5430 bool isAbruptTermination2(Statement statement) { | 5430 bool isAbruptTermination2(Statement statement) { |
| 5431 if (statement is ReturnStatement || statement is BreakStatement || statement
is ContinueStatement) { | 5431 if (statement is ReturnStatement || statement is BreakStatement || statement
is ContinueStatement) { |
| 5432 return true; | 5432 return true; |
| 5433 } else if (statement is ExpressionStatement) { | 5433 } else if (statement is ExpressionStatement) { |
| 5434 return isAbruptTermination(((statement as ExpressionStatement)).expression
); | 5434 return isAbruptTermination(((statement as ExpressionStatement)).expression
); |
| 5435 } else if (statement is Block) { | 5435 } else if (statement is Block) { |
| 5436 NodeList<Statement> statements2 = ((statement as Block)).statements; | 5436 NodeList<Statement> statements = ((statement as Block)).statements; |
| 5437 int size2 = statements2.length; | 5437 int size = statements.length; |
| 5438 if (size2 == 0) { | 5438 if (size == 0) { |
| 5439 return false; | 5439 return false; |
| 5440 } | 5440 } |
| 5441 return isAbruptTermination2(statements2[size2 - 1]); | 5441 return isAbruptTermination2(statements[size - 1]); |
| 5442 } | 5442 } |
| 5443 return false; | 5443 return false; |
| 5444 } | 5444 } |
| 5445 | 5445 |
| 5446 /** | 5446 /** |
| 5447 * Propagate any type information that results from knowing that the given con
dition will have | 5447 * Propagate any type information that results from knowing that the given con
dition will have |
| 5448 * been evaluated to 'false'. | 5448 * been evaluated to 'false'. |
| 5449 * @param condition the condition that will have evaluated to 'false' | 5449 * @param condition the condition that will have evaluated to 'false' |
| 5450 */ | 5450 */ |
| 5451 void propagateFalseState(Expression condition) { | 5451 void propagateFalseState(Expression condition) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5563 * @param library the library containing the compilation unit being resolved | 5563 * @param library the library containing the compilation unit being resolved |
| 5564 * @param source the source representing the compilation unit being visited | 5564 * @param source the source representing the compilation unit being visited |
| 5565 * @param typeProvider the object used to access the types from the core libra
ry | 5565 * @param typeProvider the object used to access the types from the core libra
ry |
| 5566 */ | 5566 */ |
| 5567 ScopedVisitor.con1(Library library, Source source2, TypeProvider typeProvider2
) { | 5567 ScopedVisitor.con1(Library library, Source source2, TypeProvider typeProvider2
) { |
| 5568 _jtd_constructor_275_impl(library, source2, typeProvider2); | 5568 _jtd_constructor_275_impl(library, source2, typeProvider2); |
| 5569 } | 5569 } |
| 5570 _jtd_constructor_275_impl(Library library, Source source2, TypeProvider typePr
ovider2) { | 5570 _jtd_constructor_275_impl(Library library, Source source2, TypeProvider typePr
ovider2) { |
| 5571 this._definingLibrary = library.libraryElement; | 5571 this._definingLibrary = library.libraryElement; |
| 5572 this._source = source2; | 5572 this._source = source2; |
| 5573 LibraryScope libraryScope2 = library.libraryScope; | 5573 LibraryScope libraryScope = library.libraryScope; |
| 5574 this._errorListener = libraryScope2.errorListener; | 5574 this._errorListener = libraryScope.errorListener; |
| 5575 this._nameScope = libraryScope2; | 5575 this._nameScope = libraryScope; |
| 5576 this._typeProvider = typeProvider2; | 5576 this._typeProvider = typeProvider2; |
| 5577 } | 5577 } |
| 5578 | 5578 |
| 5579 /** | 5579 /** |
| 5580 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 5580 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
| 5581 * @param definingLibrary the element for the library containing the compilati
on unit being | 5581 * @param definingLibrary the element for the library containing the compilati
on unit being |
| 5582 * visited | 5582 * visited |
| 5583 * @param source the source representing the compilation unit being visited | 5583 * @param source the source representing the compilation unit being visited |
| 5584 * @param typeProvider the object used to access the types from the core libra
ry | 5584 * @param typeProvider the object used to access the types from the core libra
ry |
| 5585 * @param errorListener the error listener that will be informed of any errors
that are found | 5585 * @param errorListener the error listener that will be informed of any errors
that are found |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5659 Scope outerScope = _nameScope; | 5659 Scope outerScope = _nameScope; |
| 5660 try { | 5660 try { |
| 5661 _nameScope = new FunctionScope(_nameScope, node.element); | 5661 _nameScope = new FunctionScope(_nameScope, node.element); |
| 5662 super.visitConstructorDeclaration(node); | 5662 super.visitConstructorDeclaration(node); |
| 5663 } finally { | 5663 } finally { |
| 5664 _nameScope = outerScope; | 5664 _nameScope = outerScope; |
| 5665 } | 5665 } |
| 5666 return null; | 5666 return null; |
| 5667 } | 5667 } |
| 5668 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 5668 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 5669 VariableElement element2 = node.element; | 5669 VariableElement element = node.element; |
| 5670 if (element2 != null) { | 5670 if (element != null) { |
| 5671 _nameScope.define(element2); | 5671 _nameScope.define(element); |
| 5672 } | 5672 } |
| 5673 super.visitDeclaredIdentifier(node); | 5673 super.visitDeclaredIdentifier(node); |
| 5674 return null; | 5674 return null; |
| 5675 } | 5675 } |
| 5676 Object visitDoStatement(DoStatement node) { | 5676 Object visitDoStatement(DoStatement node) { |
| 5677 LabelScope outerScope = _labelScope; | 5677 LabelScope outerScope = _labelScope; |
| 5678 _labelScope = new LabelScope.con1(outerScope, false, false); | 5678 _labelScope = new LabelScope.con1(outerScope, false, false); |
| 5679 try { | 5679 try { |
| 5680 super.visitDoStatement(node); | 5680 super.visitDoStatement(node); |
| 5681 } finally { | 5681 } finally { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5803 } | 5803 } |
| 5804 try { | 5804 try { |
| 5805 super.visitSwitchStatement(node); | 5805 super.visitSwitchStatement(node); |
| 5806 } finally { | 5806 } finally { |
| 5807 _labelScope = outerScope; | 5807 _labelScope = outerScope; |
| 5808 } | 5808 } |
| 5809 return null; | 5809 return null; |
| 5810 } | 5810 } |
| 5811 Object visitVariableDeclaration(VariableDeclaration node) { | 5811 Object visitVariableDeclaration(VariableDeclaration node) { |
| 5812 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { | 5812 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { |
| 5813 VariableElement element2 = node.element; | 5813 VariableElement element = node.element; |
| 5814 if (element2 != null) { | 5814 if (element != null) { |
| 5815 _nameScope.define(element2); | 5815 _nameScope.define(element); |
| 5816 } | 5816 } |
| 5817 } | 5817 } |
| 5818 super.visitVariableDeclaration(node); | 5818 super.visitVariableDeclaration(node); |
| 5819 return null; | 5819 return null; |
| 5820 } | 5820 } |
| 5821 Object visitWhileStatement(WhileStatement node) { | 5821 Object visitWhileStatement(WhileStatement node) { |
| 5822 LabelScope outerScope = _labelScope; | 5822 LabelScope outerScope = _labelScope; |
| 5823 _labelScope = new LabelScope.con1(outerScope, false, false); | 5823 _labelScope = new LabelScope.con1(outerScope, false, false); |
| 5824 try { | 5824 try { |
| 5825 super.visitWhileStatement(node); | 5825 super.visitWhileStatement(node); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6114 * A compound assignment of the form <i>v op= e</i> is equivalent to <i>v = v
op e</i>. A compound | 6114 * A compound assignment of the form <i>v op= e</i> is equivalent to <i>v = v
op e</i>. A compound |
| 6115 * assignment of the form <i>C.v op= e</i> is equivalent to <i>C.v = C.v op e<
/i>. A compound | 6115 * assignment of the form <i>C.v op= e</i> is equivalent to <i>C.v = C.v op e<
/i>. A compound |
| 6116 * assignment of the form <i>e<sub>1</sub>.v op= e<sub>2</sub></i> is equivale
nt to <i>((x) => x.v | 6116 * assignment of the form <i>e<sub>1</sub>.v op= e<sub>2</sub></i> is equivale
nt to <i>((x) => x.v |
| 6117 * = x.v op e<sub>2</sub>)(e<sub>1</sub>)</i> where <i>x</i> is a variable tha
t is not used in | 6117 * = x.v op e<sub>2</sub>)(e<sub>1</sub>)</i> where <i>x</i> is a variable tha
t is not used in |
| 6118 * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>\[e
<sub>2</sub>\] op= | 6118 * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>\[e
<sub>2</sub>\] op= |
| 6119 * e<sub>3</sub></i> is equivalent to <i>((a, i) => a\[i\] = a\[i\] op e<sub>3
</sub>)(e<sub>1</sub>, | 6119 * e<sub>3</sub></i> is equivalent to <i>((a, i) => a\[i\] = a\[i\] op e<sub>3
</sub>)(e<sub>1</sub>, |
| 6120 * e<sub>2</sub>)</i> where <i>a</i> and <i>i</i> are a variables that are not
used in | 6120 * e<sub>2</sub>)</i> where <i>a</i> and <i>i</i> are a variables that are not
used in |
| 6121 * <i>e<sub>3</sub></i>.</blockquote> | 6121 * <i>e<sub>3</sub></i>.</blockquote> |
| 6122 */ | 6122 */ |
| 6123 Object visitAssignmentExpression(AssignmentExpression node) { | 6123 Object visitAssignmentExpression(AssignmentExpression node) { |
| 6124 sc.TokenType operator2 = node.operator.type; | 6124 sc.TokenType operator = node.operator.type; |
| 6125 if (identical(operator2, sc.TokenType.EQ)) { | 6125 if (identical(operator, sc.TokenType.EQ)) { |
| 6126 Expression rightHandSide2 = node.rightHandSide; | 6126 Expression rightHandSide = node.rightHandSide; |
| 6127 Type2 staticType = getStaticType(rightHandSide2); | 6127 Type2 staticType = getStaticType(rightHandSide); |
| 6128 recordStaticType(node, staticType); | 6128 recordStaticType(node, staticType); |
| 6129 Type2 overrideType = staticType; | 6129 Type2 overrideType = staticType; |
| 6130 Type2 propagatedType = getPropagatedType(rightHandSide2); | 6130 Type2 propagatedType = getPropagatedType(rightHandSide); |
| 6131 if (propagatedType != null) { | 6131 if (propagatedType != null) { |
| 6132 if (propagatedType.isMoreSpecificThan(staticType)) { | 6132 if (propagatedType.isMoreSpecificThan(staticType)) { |
| 6133 recordPropagatedType(node, propagatedType); | 6133 recordPropagatedType(node, propagatedType); |
| 6134 } | 6134 } |
| 6135 overrideType = propagatedType; | 6135 overrideType = propagatedType; |
| 6136 } | 6136 } |
| 6137 VariableElement element = _resolver.getOverridableElement(node.leftHandSid
e); | 6137 VariableElement element = _resolver.getOverridableElement(node.leftHandSid
e); |
| 6138 if (element != null) { | 6138 if (element != null) { |
| 6139 _resolver.override(element, overrideType); | 6139 _resolver.override(element, overrideType); |
| 6140 } | 6140 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6383 * The Dart Language Specification, 12.11.1: <blockquote>The static type of a
new expression of | 6383 * The Dart Language Specification, 12.11.1: <blockquote>The static type of a
new expression of |
| 6384 * either the form <i>new T.id(a<sub>1</sub>, …, a<sub>n</sub>)</i> or
the form <i>new | 6384 * either the form <i>new T.id(a<sub>1</sub>, …, a<sub>n</sub>)</i> or
the form <i>new |
| 6385 * T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>.</blockquote> | 6385 * T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>.</blockquote> |
| 6386 * <p> | 6386 * <p> |
| 6387 * The Dart Language Specification, 12.11.2: <blockquote>The static type of a
constant object | 6387 * The Dart Language Specification, 12.11.2: <blockquote>The static type of a
constant object |
| 6388 * expression of either the form <i>const T.id(a<sub>1</sub>, …, a<sub>
n</sub>)</i> or the | 6388 * expression of either the form <i>const T.id(a<sub>1</sub>, …, a<sub>
n</sub>)</i> or the |
| 6389 * form <i>const T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>. </
blockquote> | 6389 * form <i>const T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>. </
blockquote> |
| 6390 */ | 6390 */ |
| 6391 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 6391 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 6392 recordStaticType(node, node.constructorName.type.type); | 6392 recordStaticType(node, node.constructorName.type.type); |
| 6393 ConstructorElement element2 = node.element; | 6393 ConstructorElement element = node.element; |
| 6394 if (element2 != null && "Element" == element2.enclosingElement.name && "tag"
== element2.name) { | 6394 if (element != null && "Element" == element.enclosingElement.name && "tag" =
= element.name) { |
| 6395 LibraryElement library2 = element2.library; | 6395 LibraryElement library = element.library; |
| 6396 if (isHtmlLibrary(library2)) { | 6396 if (isHtmlLibrary(library)) { |
| 6397 Type2 returnType = getFirstArgumentAsType2(library2, node.argumentList,
_HTML_ELEMENT_TO_CLASS_MAP); | 6397 Type2 returnType = getFirstArgumentAsType2(library, node.argumentList, _
HTML_ELEMENT_TO_CLASS_MAP); |
| 6398 if (returnType != null) { | 6398 if (returnType != null) { |
| 6399 recordPropagatedType(node, returnType); | 6399 recordPropagatedType(node, returnType); |
| 6400 } | 6400 } |
| 6401 } | 6401 } |
| 6402 } | 6402 } |
| 6403 return null; | 6403 return null; |
| 6404 } | 6404 } |
| 6405 | 6405 |
| 6406 /** | 6406 /** |
| 6407 * The Dart Language Specification, 12.3: <blockquote>The static type of an in
teger literal is{@code int}.</blockquote> | 6407 * The Dart Language Specification, 12.3: <blockquote>The static type of an in
teger literal is{@code int}.</blockquote> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6424 | 6424 |
| 6425 /** | 6425 /** |
| 6426 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis
t literal of the | 6426 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis
t literal of the |
| 6427 * form <i><b>const</b> <E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i
> or the form | 6427 * form <i><b>const</b> <E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i
> or the form |
| 6428 * <i><E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List&l
t;E>}. The static | 6428 * <i><E>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List&l
t;E>}. The static |
| 6429 * type a list literal of the form <i><b>const</b> \[e<sub>1</sub>, …,
e<sub>n</sub>\]</i> or | 6429 * type a list literal of the form <i><b>const</b> \[e<sub>1</sub>, …,
e<sub>n</sub>\]</i> or |
| 6430 * the form <i>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List&l
t;dynamic>}.</blockquote> | 6430 * the form <i>\[e<sub>1</sub>, …, e<sub>n</sub>\]</i> is {@code List&l
t;dynamic>}.</blockquote> |
| 6431 */ | 6431 */ |
| 6432 Object visitListLiteral(ListLiteral node) { | 6432 Object visitListLiteral(ListLiteral node) { |
| 6433 Type2 staticType = _dynamicType; | 6433 Type2 staticType = _dynamicType; |
| 6434 TypeArgumentList typeArguments2 = node.typeArguments; | 6434 TypeArgumentList typeArguments = node.typeArguments; |
| 6435 if (typeArguments2 != null) { | 6435 if (typeArguments != null) { |
| 6436 NodeList<TypeName> arguments2 = typeArguments2.arguments; | 6436 NodeList<TypeName> arguments = typeArguments.arguments; |
| 6437 if (arguments2 != null && arguments2.length == 1) { | 6437 if (arguments != null && arguments.length == 1) { |
| 6438 TypeName argumentTypeName = arguments2[0]; | 6438 TypeName argumentTypeName = arguments[0]; |
| 6439 Type2 argumentType = getType2(argumentTypeName); | 6439 Type2 argumentType = getType2(argumentTypeName); |
| 6440 if (argumentType != null) { | 6440 if (argumentType != null) { |
| 6441 staticType = argumentType; | 6441 staticType = argumentType; |
| 6442 } | 6442 } |
| 6443 } | 6443 } |
| 6444 } | 6444 } |
| 6445 recordStaticType(node, _typeProvider.listType.substitute5(<Type2> [staticTyp
e])); | 6445 recordStaticType(node, _typeProvider.listType.substitute5(<Type2> [staticTyp
e])); |
| 6446 NodeList<Expression> elements2 = node.elements; | 6446 NodeList<Expression> elements = node.elements; |
| 6447 int count = elements2.length; | 6447 int count = elements.length; |
| 6448 if (count > 0) { | 6448 if (count > 0) { |
| 6449 Type2 propagatedType = getBestType(elements2[0]); | 6449 Type2 propagatedType = getBestType(elements[0]); |
| 6450 for (int i = 1; i < count; i++) { | 6450 for (int i = 1; i < count; i++) { |
| 6451 Type2 elementType = getBestType(elements2[i]); | 6451 Type2 elementType = getBestType(elements[i]); |
| 6452 if (propagatedType != elementType) { | 6452 if (propagatedType != elementType) { |
| 6453 propagatedType = _dynamicType; | 6453 propagatedType = _dynamicType; |
| 6454 } else { | 6454 } else { |
| 6455 propagatedType = propagatedType.getLeastUpperBound(elementType); | 6455 propagatedType = propagatedType.getLeastUpperBound(elementType); |
| 6456 if (propagatedType == null) { | 6456 if (propagatedType == null) { |
| 6457 propagatedType = _dynamicType; | 6457 propagatedType = _dynamicType; |
| 6458 } | 6458 } |
| 6459 } | 6459 } |
| 6460 } | 6460 } |
| 6461 if (propagatedType.isMoreSpecificThan(staticType)) { | 6461 if (propagatedType.isMoreSpecificThan(staticType)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6473 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell
ip;, | 6473 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell
ip;, |
| 6474 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub
>, …, | 6474 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub
>, …, |
| 6475 * k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map<String, dynamic>}. | 6475 * k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map<String, dynamic>}. |
| 6476 * <p> | 6476 * <p> |
| 6477 * It is a compile-time error if the first type argument to a map literal is n
ot | 6477 * It is a compile-time error if the first type argument to a map literal is n
ot |
| 6478 * <i>String</i>.</blockquote> | 6478 * <i>String</i>.</blockquote> |
| 6479 */ | 6479 */ |
| 6480 Object visitMapLiteral(MapLiteral node) { | 6480 Object visitMapLiteral(MapLiteral node) { |
| 6481 Type2 staticKeyType = _dynamicType; | 6481 Type2 staticKeyType = _dynamicType; |
| 6482 Type2 staticValueType = _dynamicType; | 6482 Type2 staticValueType = _dynamicType; |
| 6483 TypeArgumentList typeArguments2 = node.typeArguments; | 6483 TypeArgumentList typeArguments = node.typeArguments; |
| 6484 if (typeArguments2 != null) { | 6484 if (typeArguments != null) { |
| 6485 NodeList<TypeName> arguments2 = typeArguments2.arguments; | 6485 NodeList<TypeName> arguments = typeArguments.arguments; |
| 6486 if (arguments2 != null && arguments2.length == 2) { | 6486 if (arguments != null && arguments.length == 2) { |
| 6487 TypeName entryKeyTypeName = arguments2[0]; | 6487 TypeName entryKeyTypeName = arguments[0]; |
| 6488 Type2 entryKeyType = getType2(entryKeyTypeName); | 6488 Type2 entryKeyType = getType2(entryKeyTypeName); |
| 6489 if (entryKeyType != null) { | 6489 if (entryKeyType != null) { |
| 6490 staticKeyType = entryKeyType; | 6490 staticKeyType = entryKeyType; |
| 6491 } | 6491 } |
| 6492 TypeName entryValueTypeName = arguments2[1]; | 6492 TypeName entryValueTypeName = arguments[1]; |
| 6493 Type2 entryValueType = getType2(entryValueTypeName); | 6493 Type2 entryValueType = getType2(entryValueTypeName); |
| 6494 if (entryValueType != null) { | 6494 if (entryValueType != null) { |
| 6495 staticValueType = entryValueType; | 6495 staticValueType = entryValueType; |
| 6496 } | 6496 } |
| 6497 } | 6497 } |
| 6498 } | 6498 } |
| 6499 recordStaticType(node, _typeProvider.mapType.substitute5(<Type2> [staticKeyT
ype, staticValueType])); | 6499 recordStaticType(node, _typeProvider.mapType.substitute5(<Type2> [staticKeyT
ype, staticValueType])); |
| 6500 NodeList<MapLiteralEntry> entries2 = node.entries; | 6500 NodeList<MapLiteralEntry> entries = node.entries; |
| 6501 int count = entries2.length; | 6501 int count = entries.length; |
| 6502 if (count > 0) { | 6502 if (count > 0) { |
| 6503 MapLiteralEntry entry = entries2[0]; | 6503 MapLiteralEntry entry = entries[0]; |
| 6504 Type2 propagatedKeyType = getBestType(entry.key); | 6504 Type2 propagatedKeyType = getBestType(entry.key); |
| 6505 Type2 propagatedValueType = getBestType(entry.value); | 6505 Type2 propagatedValueType = getBestType(entry.value); |
| 6506 for (int i = 1; i < count; i++) { | 6506 for (int i = 1; i < count; i++) { |
| 6507 entry = entries2[i]; | 6507 entry = entries[i]; |
| 6508 Type2 elementKeyType = getBestType(entry.key); | 6508 Type2 elementKeyType = getBestType(entry.key); |
| 6509 if (propagatedKeyType != elementKeyType) { | 6509 if (propagatedKeyType != elementKeyType) { |
| 6510 propagatedKeyType = _dynamicType; | 6510 propagatedKeyType = _dynamicType; |
| 6511 } else { | 6511 } else { |
| 6512 propagatedKeyType = propagatedKeyType.getLeastUpperBound(elementKeyTyp
e); | 6512 propagatedKeyType = propagatedKeyType.getLeastUpperBound(elementKeyTyp
e); |
| 6513 if (propagatedKeyType == null) { | 6513 if (propagatedKeyType == null) { |
| 6514 propagatedKeyType = _dynamicType; | 6514 propagatedKeyType = _dynamicType; |
| 6515 } | 6515 } |
| 6516 } | 6516 } |
| 6517 Type2 elementValueType = getBestType(entry.value); | 6517 Type2 elementValueType = getBestType(entry.value); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6582 staticMethodElement = methodNameNode.element; | 6582 staticMethodElement = methodNameNode.element; |
| 6583 } | 6583 } |
| 6584 Type2 staticType = computeReturnType(staticMethodElement); | 6584 Type2 staticType = computeReturnType(staticMethodElement); |
| 6585 recordStaticType(node, staticType); | 6585 recordStaticType(node, staticType); |
| 6586 String methodName = methodNameNode.name; | 6586 String methodName = methodNameNode.name; |
| 6587 if (methodName == "\$dom_createEvent") { | 6587 if (methodName == "\$dom_createEvent") { |
| 6588 Expression target = node.realTarget; | 6588 Expression target = node.realTarget; |
| 6589 if (target != null) { | 6589 if (target != null) { |
| 6590 Type2 targetType = getBestType(target); | 6590 Type2 targetType = getBestType(target); |
| 6591 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" ||
targetType.name == "Document")) { | 6591 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" ||
targetType.name == "Document")) { |
| 6592 LibraryElement library2 = targetType.element.library; | 6592 LibraryElement library = targetType.element.library; |
| 6593 if (isHtmlLibrary(library2)) { | 6593 if (isHtmlLibrary(library)) { |
| 6594 Type2 returnType = getFirstArgumentAsType(library2, node.argumentLis
t); | 6594 Type2 returnType = getFirstArgumentAsType(library, node.argumentList
); |
| 6595 if (returnType != null) { | 6595 if (returnType != null) { |
| 6596 recordPropagatedType(node, returnType); | 6596 recordPropagatedType(node, returnType); |
| 6597 } | 6597 } |
| 6598 } | 6598 } |
| 6599 } | 6599 } |
| 6600 } | 6600 } |
| 6601 } else if (methodName == "query") { | 6601 } else if (methodName == "query") { |
| 6602 Expression target = node.realTarget; | 6602 Expression target = node.realTarget; |
| 6603 if (target == null) { | 6603 if (target == null) { |
| 6604 Element methodElement = methodNameNode.element; | 6604 Element methodElement = methodNameNode.element; |
| 6605 if (methodElement != null) { | 6605 if (methodElement != null) { |
| 6606 LibraryElement library3 = methodElement.library; | 6606 LibraryElement library = methodElement.library; |
| 6607 if (isHtmlLibrary(library3)) { | 6607 if (isHtmlLibrary(library)) { |
| 6608 Type2 returnType = getFirstArgumentAsQuery(library3, node.argumentLi
st); | 6608 Type2 returnType = getFirstArgumentAsQuery(library, node.argumentLis
t); |
| 6609 if (returnType != null) { | 6609 if (returnType != null) { |
| 6610 recordPropagatedType(node, returnType); | 6610 recordPropagatedType(node, returnType); |
| 6611 } | 6611 } |
| 6612 } | 6612 } |
| 6613 } | 6613 } |
| 6614 } else { | 6614 } else { |
| 6615 Type2 targetType = getBestType(target); | 6615 Type2 targetType = getBestType(target); |
| 6616 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" ||
targetType.name == "Document")) { | 6616 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" ||
targetType.name == "Document")) { |
| 6617 LibraryElement library4 = targetType.element.library; | 6617 LibraryElement library = targetType.element.library; |
| 6618 if (isHtmlLibrary(library4)) { | 6618 if (isHtmlLibrary(library)) { |
| 6619 Type2 returnType = getFirstArgumentAsQuery(library4, node.argumentLi
st); | 6619 Type2 returnType = getFirstArgumentAsQuery(library, node.argumentLis
t); |
| 6620 if (returnType != null) { | 6620 if (returnType != null) { |
| 6621 recordPropagatedType(node, returnType); | 6621 recordPropagatedType(node, returnType); |
| 6622 } | 6622 } |
| 6623 } | 6623 } |
| 6624 } | 6624 } |
| 6625 } | 6625 } |
| 6626 } else if (methodName == "\$dom_createElement") { | 6626 } else if (methodName == "\$dom_createElement") { |
| 6627 Expression target = node.realTarget; | 6627 Expression target = node.realTarget; |
| 6628 Type2 targetType = getBestType(target); | 6628 Type2 targetType = getBestType(target); |
| 6629 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" || t
argetType.name == "Document")) { | 6629 if (targetType is InterfaceType && (targetType.name == "HtmlDocument" || t
argetType.name == "Document")) { |
| 6630 LibraryElement library5 = targetType.element.library; | 6630 LibraryElement library = targetType.element.library; |
| 6631 if (isHtmlLibrary(library5)) { | 6631 if (isHtmlLibrary(library)) { |
| 6632 Type2 returnType = getFirstArgumentAsQuery(library5, node.argumentList
); | 6632 Type2 returnType = getFirstArgumentAsQuery(library, node.argumentList)
; |
| 6633 if (returnType != null) { | 6633 if (returnType != null) { |
| 6634 recordPropagatedType(node, returnType); | 6634 recordPropagatedType(node, returnType); |
| 6635 } | 6635 } |
| 6636 } | 6636 } |
| 6637 } | 6637 } |
| 6638 } else if (methodName == "JS") { | 6638 } else if (methodName == "JS") { |
| 6639 Type2 returnType = getFirstArgumentAsType(_typeProvider.objectType.element
.library, node.argumentList); | 6639 Type2 returnType = getFirstArgumentAsType(_typeProvider.objectType.element
.library, node.argumentList); |
| 6640 if (returnType != null) { | 6640 if (returnType != null) { |
| 6641 recordPropagatedType(node, returnType); | 6641 recordPropagatedType(node, returnType); |
| 6642 } | 6642 } |
| 6643 } else { | 6643 } else { |
| 6644 Element propagatedElement = methodNameNode.element; | 6644 Element propagatedElement = methodNameNode.element; |
| 6645 if (propagatedElement != staticMethodElement) { | 6645 if (propagatedElement != staticMethodElement) { |
| 6646 Type2 propagatedType = computeReturnType(propagatedElement); | 6646 Type2 propagatedType = computeReturnType(propagatedElement); |
| 6647 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { | 6647 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { |
| 6648 recordPropagatedType(node, propagatedType); | 6648 recordPropagatedType(node, propagatedType); |
| 6649 } | 6649 } |
| 6650 } | 6650 } |
| 6651 } | 6651 } |
| 6652 return null; | 6652 return null; |
| 6653 } | 6653 } |
| 6654 Object visitNamedExpression(NamedExpression node) { | 6654 Object visitNamedExpression(NamedExpression node) { |
| 6655 Expression expression2 = node.expression; | 6655 Expression expression = node.expression; |
| 6656 recordStaticType(node, getStaticType(expression2)); | 6656 recordStaticType(node, getStaticType(expression)); |
| 6657 recordPropagatedType(node, getPropagatedType(expression2)); | 6657 recordPropagatedType(node, getPropagatedType(expression)); |
| 6658 return null; | 6658 return null; |
| 6659 } | 6659 } |
| 6660 | 6660 |
| 6661 /** | 6661 /** |
| 6662 * The Dart Language Specification, 12.2: <blockquote>The static type of {@cod
e null} is bottom. | 6662 * The Dart Language Specification, 12.2: <blockquote>The static type of {@cod
e null} is bottom. |
| 6663 * </blockquote> | 6663 * </blockquote> |
| 6664 */ | 6664 */ |
| 6665 Object visitNullLiteral(NullLiteral node) { | 6665 Object visitNullLiteral(NullLiteral node) { |
| 6666 recordStaticType(node, _typeProvider.bottomType); | 6666 recordStaticType(node, _typeProvider.bottomType); |
| 6667 return null; | 6667 return null; |
| 6668 } | 6668 } |
| 6669 Object visitParenthesizedExpression(ParenthesizedExpression node) { | 6669 Object visitParenthesizedExpression(ParenthesizedExpression node) { |
| 6670 Expression expression2 = node.expression; | 6670 Expression expression = node.expression; |
| 6671 recordStaticType(node, getStaticType(expression2)); | 6671 recordStaticType(node, getStaticType(expression)); |
| 6672 recordPropagatedType(node, getPropagatedType(expression2)); | 6672 recordPropagatedType(node, getPropagatedType(expression)); |
| 6673 return null; | 6673 return null; |
| 6674 } | 6674 } |
| 6675 | 6675 |
| 6676 /** | 6676 /** |
| 6677 * The Dart Language Specification, 12.28: <blockquote>A postfix expression of
the form | 6677 * The Dart Language Specification, 12.28: <blockquote>A postfix expression of
the form |
| 6678 * <i>v++</i>, where <i>v</i> is an identifier, is equivalent to <i>(){var r =
v; v = r + 1; | 6678 * <i>v++</i>, where <i>v</i> is an identifier, is equivalent to <i>(){var r =
v; v = r + 1; |
| 6679 * return r}()</i>. | 6679 * return r}()</i>. |
| 6680 * <p> | 6680 * <p> |
| 6681 * A postfix expression of the form <i>C.v++</i> is equivalent to <i>(){var r
= C.v; C.v = r + 1; | 6681 * A postfix expression of the form <i>C.v++</i> is equivalent to <i>(){var r
= C.v; C.v = r + 1; |
| 6682 * return r}()</i>. | 6682 * return r}()</i>. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6693 * A postfix expression of the form <i>C.v--</i> is equivalent to <i>(){var r
= C.v; C.v = r - 1; | 6693 * A postfix expression of the form <i>C.v--</i> is equivalent to <i>(){var r
= C.v; C.v = r - 1; |
| 6694 * return r}()</i>. | 6694 * return r}()</i>. |
| 6695 * <p> | 6695 * <p> |
| 6696 * A postfix expression of the form <i>e1.v--</i> is equivalent to <i>(x){var
r = x.v; x.v = r - | 6696 * A postfix expression of the form <i>e1.v--</i> is equivalent to <i>(x){var
r = x.v; x.v = r - |
| 6697 * 1; return r}(e1)</i>. | 6697 * 1; return r}(e1)</i>. |
| 6698 * <p> | 6698 * <p> |
| 6699 * A postfix expression of the form <i>e1\[e2\]--</i> is equivalent to <i>(a,
i){var r = a\[i\]; a\[i\] | 6699 * A postfix expression of the form <i>e1\[e2\]--</i> is equivalent to <i>(a,
i){var r = a\[i\]; a\[i\] |
| 6700 * = r - 1; return r}(e1, e2)</i></blockquote> | 6700 * = r - 1; return r}(e1, e2)</i></blockquote> |
| 6701 */ | 6701 */ |
| 6702 Object visitPostfixExpression(PostfixExpression node) { | 6702 Object visitPostfixExpression(PostfixExpression node) { |
| 6703 Expression operand2 = node.operand; | 6703 Expression operand = node.operand; |
| 6704 Type2 staticType = getStaticType(operand2); | 6704 Type2 staticType = getStaticType(operand); |
| 6705 sc.TokenType operator2 = node.operator.type; | 6705 sc.TokenType operator = node.operator.type; |
| 6706 if (identical(operator2, sc.TokenType.MINUS_MINUS) || identical(operator2, s
c.TokenType.PLUS_PLUS)) { | 6706 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, sc.
TokenType.PLUS_PLUS)) { |
| 6707 Type2 intType2 = _typeProvider.intType; | 6707 Type2 intType = _typeProvider.intType; |
| 6708 if (identical(getStaticType(node.operand), intType2)) { | 6708 if (identical(getStaticType(node.operand), intType)) { |
| 6709 staticType = intType2; | 6709 staticType = intType; |
| 6710 } | 6710 } |
| 6711 } | 6711 } |
| 6712 recordStaticType(node, staticType); | 6712 recordStaticType(node, staticType); |
| 6713 recordPropagatedType(node, getPropagatedType(operand2)); | 6713 recordPropagatedType(node, getPropagatedType(operand)); |
| 6714 return null; | 6714 return null; |
| 6715 } | 6715 } |
| 6716 | 6716 |
| 6717 /** | 6717 /** |
| 6718 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}. | 6718 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}. |
| 6719 */ | 6719 */ |
| 6720 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 6720 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 6721 SimpleIdentifier prefixedIdentifier = node.identifier; | 6721 SimpleIdentifier prefixedIdentifier = node.identifier; |
| 6722 Element element2 = prefixedIdentifier.element; | 6722 Element element = prefixedIdentifier.element; |
| 6723 Type2 staticType = _dynamicType; | 6723 Type2 staticType = _dynamicType; |
| 6724 if (element2 is ClassElement) { | 6724 if (element is ClassElement) { |
| 6725 if (isNotTypeLiteral(node)) { | 6725 if (isNotTypeLiteral(node)) { |
| 6726 staticType = ((element2 as ClassElement)).type; | 6726 staticType = ((element as ClassElement)).type; |
| 6727 } else { | 6727 } else { |
| 6728 staticType = _typeProvider.typeType; | 6728 staticType = _typeProvider.typeType; |
| 6729 } | 6729 } |
| 6730 } else if (element2 is FunctionTypeAliasElement) { | 6730 } else if (element is FunctionTypeAliasElement) { |
| 6731 staticType = ((element2 as FunctionTypeAliasElement)).type; | 6731 staticType = ((element as FunctionTypeAliasElement)).type; |
| 6732 } else if (element2 is MethodElement) { | 6732 } else if (element is MethodElement) { |
| 6733 staticType = ((element2 as MethodElement)).type; | 6733 staticType = ((element as MethodElement)).type; |
| 6734 } else if (element2 is PropertyAccessorElement) { | 6734 } else if (element is PropertyAccessorElement) { |
| 6735 staticType = getType((element2 as PropertyAccessorElement), node.prefix.st
aticType); | 6735 staticType = getType((element as PropertyAccessorElement), node.prefix.sta
ticType); |
| 6736 } else if (element2 is ExecutableElement) { | 6736 } else if (element is ExecutableElement) { |
| 6737 staticType = ((element2 as ExecutableElement)).type; | 6737 staticType = ((element as ExecutableElement)).type; |
| 6738 } else if (element2 is TypeVariableElement) { | 6738 } else if (element is TypeVariableElement) { |
| 6739 staticType = ((element2 as TypeVariableElement)).type; | 6739 staticType = ((element as TypeVariableElement)).type; |
| 6740 } else if (element2 is VariableElement) { | 6740 } else if (element is VariableElement) { |
| 6741 staticType = ((element2 as VariableElement)).type; | 6741 staticType = ((element as VariableElement)).type; |
| 6742 } | 6742 } |
| 6743 recordStaticType(prefixedIdentifier, staticType); | 6743 recordStaticType(prefixedIdentifier, staticType); |
| 6744 recordStaticType(node, staticType); | 6744 recordStaticType(node, staticType); |
| 6745 Type2 propagatedType = _overrideManager.getType(element2); | 6745 Type2 propagatedType = _overrideManager.getType(element); |
| 6746 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ | 6746 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ |
| 6747 recordPropagatedType(prefixedIdentifier, propagatedType); | 6747 recordPropagatedType(prefixedIdentifier, propagatedType); |
| 6748 recordPropagatedType(node, propagatedType); | 6748 recordPropagatedType(node, propagatedType); |
| 6749 } | 6749 } |
| 6750 return null; | 6750 return null; |
| 6751 } | 6751 } |
| 6752 | 6752 |
| 6753 /** | 6753 /** |
| 6754 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form | 6754 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form |
| 6755 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the | 6755 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the |
| 6756 * form <i>op super</i> is equivalent to the method invocation <i>super.op()<i
>.</blockquote> | 6756 * form <i>op super</i> is equivalent to the method invocation <i>super.op()<i
>.</blockquote> |
| 6757 */ | 6757 */ |
| 6758 Object visitPrefixExpression(PrefixExpression node) { | 6758 Object visitPrefixExpression(PrefixExpression node) { |
| 6759 sc.TokenType operator2 = node.operator.type; | 6759 sc.TokenType operator = node.operator.type; |
| 6760 if (identical(operator2, sc.TokenType.BANG)) { | 6760 if (identical(operator, sc.TokenType.BANG)) { |
| 6761 recordStaticType(node, _typeProvider.boolType); | 6761 recordStaticType(node, _typeProvider.boolType); |
| 6762 } else { | 6762 } else { |
| 6763 ExecutableElement staticMethodElement = node.staticElement; | 6763 ExecutableElement staticMethodElement = node.staticElement; |
| 6764 Type2 staticType = computeReturnType(staticMethodElement); | 6764 Type2 staticType = computeReturnType(staticMethodElement); |
| 6765 if (identical(operator2, sc.TokenType.MINUS_MINUS) || identical(operator2,
sc.TokenType.PLUS_PLUS)) { | 6765 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, s
c.TokenType.PLUS_PLUS)) { |
| 6766 Type2 intType2 = _typeProvider.intType; | 6766 Type2 intType = _typeProvider.intType; |
| 6767 if (identical(getStaticType(node.operand), intType2)) { | 6767 if (identical(getStaticType(node.operand), intType)) { |
| 6768 staticType = intType2; | 6768 staticType = intType; |
| 6769 } | 6769 } |
| 6770 } | 6770 } |
| 6771 recordStaticType(node, staticType); | 6771 recordStaticType(node, staticType); |
| 6772 MethodElement propagatedMethodElement = node.element; | 6772 MethodElement propagatedMethodElement = node.element; |
| 6773 if (propagatedMethodElement != staticMethodElement) { | 6773 if (propagatedMethodElement != staticMethodElement) { |
| 6774 Type2 propagatedType = computeReturnType(propagatedMethodElement); | 6774 Type2 propagatedType = computeReturnType(propagatedMethodElement); |
| 6775 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { | 6775 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { |
| 6776 recordPropagatedType(node, propagatedType); | 6776 recordPropagatedType(node, propagatedType); |
| 6777 } | 6777 } |
| 6778 } | 6778 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6817 * <p> | 6817 * <p> |
| 6818 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic | 6818 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic |
| 6819 * otherwise. | 6819 * otherwise. |
| 6820 * <p> | 6820 * <p> |
| 6821 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an | 6821 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an |
| 6822 * identifier ... | 6822 * identifier ... |
| 6823 * <p> | 6823 * <p> |
| 6824 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> | 6824 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> |
| 6825 */ | 6825 */ |
| 6826 Object visitPropertyAccess(PropertyAccess node) { | 6826 Object visitPropertyAccess(PropertyAccess node) { |
| 6827 SimpleIdentifier propertyName2 = node.propertyName; | 6827 SimpleIdentifier propertyName = node.propertyName; |
| 6828 Element element2 = propertyName2.element; | 6828 Element element = propertyName.element; |
| 6829 Type2 staticType = _dynamicType; | 6829 Type2 staticType = _dynamicType; |
| 6830 if (element2 is MethodElement) { | 6830 if (element is MethodElement) { |
| 6831 staticType = ((element2 as MethodElement)).type; | 6831 staticType = ((element as MethodElement)).type; |
| 6832 } else if (element2 is PropertyAccessorElement) { | 6832 } else if (element is PropertyAccessorElement) { |
| 6833 staticType = getType((element2 as PropertyAccessorElement), node.target !=
null ? getStaticType(node.target) : null); | 6833 staticType = getType((element as PropertyAccessorElement), node.target !=
null ? getStaticType(node.target) : null); |
| 6834 } else { | 6834 } else { |
| 6835 } | 6835 } |
| 6836 recordStaticType(propertyName2, staticType); | 6836 recordStaticType(propertyName, staticType); |
| 6837 recordStaticType(node, staticType); | 6837 recordStaticType(node, staticType); |
| 6838 Type2 propagatedType = _overrideManager.getType(element2); | 6838 Type2 propagatedType = _overrideManager.getType(element); |
| 6839 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ | 6839 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ |
| 6840 recordPropagatedType(node, propagatedType); | 6840 recordPropagatedType(node, propagatedType); |
| 6841 } | 6841 } |
| 6842 return null; | 6842 return null; |
| 6843 } | 6843 } |
| 6844 | 6844 |
| 6845 /** | 6845 /** |
| 6846 * The Dart Language Specification, 12.9: <blockquote>The static type of a ret
hrow expression is | 6846 * The Dart Language Specification, 12.9: <blockquote>The static type of a ret
hrow expression is |
| 6847 * bottom.</blockquote> | 6847 * bottom.</blockquote> |
| 6848 */ | 6848 */ |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6887 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is
equivalent to the | 6887 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is
equivalent to the |
| 6888 * getter invocation <i>id</i>. | 6888 * getter invocation <i>id</i>. |
| 6889 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be
it function, | 6889 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be
it function, |
| 6890 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError | 6890 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError |
| 6891 * to be thrown. | 6891 * to be thrown. |
| 6892 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id<
/i>. | 6892 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id<
/i>. |
| 6893 * </ul> | 6893 * </ul> |
| 6894 * </blockquote> | 6894 * </blockquote> |
| 6895 */ | 6895 */ |
| 6896 Object visitSimpleIdentifier(SimpleIdentifier node) { | 6896 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 6897 Element element2 = node.element; | 6897 Element element = node.element; |
| 6898 Type2 staticType = _dynamicType; | 6898 Type2 staticType = _dynamicType; |
| 6899 if (element2 is ClassElement) { | 6899 if (element is ClassElement) { |
| 6900 if (isNotTypeLiteral(node)) { | 6900 if (isNotTypeLiteral(node)) { |
| 6901 staticType = ((element2 as ClassElement)).type; | 6901 staticType = ((element as ClassElement)).type; |
| 6902 } else { | 6902 } else { |
| 6903 staticType = _typeProvider.typeType; | 6903 staticType = _typeProvider.typeType; |
| 6904 } | 6904 } |
| 6905 } else if (element2 is FunctionTypeAliasElement) { | 6905 } else if (element is FunctionTypeAliasElement) { |
| 6906 staticType = ((element2 as FunctionTypeAliasElement)).type; | 6906 staticType = ((element as FunctionTypeAliasElement)).type; |
| 6907 } else if (element2 is MethodElement) { | 6907 } else if (element is MethodElement) { |
| 6908 staticType = ((element2 as MethodElement)).type; | 6908 staticType = ((element as MethodElement)).type; |
| 6909 } else if (element2 is PropertyAccessorElement) { | 6909 } else if (element is PropertyAccessorElement) { |
| 6910 staticType = getType((element2 as PropertyAccessorElement), null); | 6910 staticType = getType((element as PropertyAccessorElement), null); |
| 6911 } else if (element2 is ExecutableElement) { | 6911 } else if (element is ExecutableElement) { |
| 6912 staticType = ((element2 as ExecutableElement)).type; | 6912 staticType = ((element as ExecutableElement)).type; |
| 6913 } else if (element2 is TypeVariableElement) { | 6913 } else if (element is TypeVariableElement) { |
| 6914 staticType = ((element2 as TypeVariableElement)).type; | 6914 staticType = ((element as TypeVariableElement)).type; |
| 6915 } else if (element2 is VariableElement) { | 6915 } else if (element is VariableElement) { |
| 6916 staticType = ((element2 as VariableElement)).type; | 6916 staticType = ((element as VariableElement)).type; |
| 6917 } else if (element2 is PrefixElement) { | 6917 } else if (element is PrefixElement) { |
| 6918 return null; | 6918 return null; |
| 6919 } else { | 6919 } else { |
| 6920 staticType = _dynamicType; | 6920 staticType = _dynamicType; |
| 6921 } | 6921 } |
| 6922 recordStaticType(node, staticType); | 6922 recordStaticType(node, staticType); |
| 6923 Type2 propagatedType = _overrideManager.getType(element2); | 6923 Type2 propagatedType = _overrideManager.getType(element); |
| 6924 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ | 6924 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ |
| 6925 recordPropagatedType(node, propagatedType); | 6925 recordPropagatedType(node, propagatedType); |
| 6926 } | 6926 } |
| 6927 return null; | 6927 return null; |
| 6928 } | 6928 } |
| 6929 | 6929 |
| 6930 /** | 6930 /** |
| 6931 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is{@code String}.</blockquote> | 6931 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is{@code String}.</blockquote> |
| 6932 */ | 6932 */ |
| 6933 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | 6933 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6966 | 6966 |
| 6967 /** | 6967 /** |
| 6968 * The Dart Language Specification, 12.8: <blockquote>The static type of a thr
ow expression is | 6968 * The Dart Language Specification, 12.8: <blockquote>The static type of a thr
ow expression is |
| 6969 * bottom.</blockquote> | 6969 * bottom.</blockquote> |
| 6970 */ | 6970 */ |
| 6971 Object visitThrowExpression(ThrowExpression node) { | 6971 Object visitThrowExpression(ThrowExpression node) { |
| 6972 recordStaticType(node, _typeProvider.bottomType); | 6972 recordStaticType(node, _typeProvider.bottomType); |
| 6973 return null; | 6973 return null; |
| 6974 } | 6974 } |
| 6975 Object visitVariableDeclaration(VariableDeclaration node) { | 6975 Object visitVariableDeclaration(VariableDeclaration node) { |
| 6976 Expression initializer2 = node.initializer; | 6976 Expression initializer = node.initializer; |
| 6977 if (initializer2 != null) { | 6977 if (initializer != null) { |
| 6978 Type2 rightType = getBestType(initializer2); | 6978 Type2 rightType = getBestType(initializer); |
| 6979 VariableElement element2 = node.name.element as VariableElement; | 6979 VariableElement element = node.name.element as VariableElement; |
| 6980 if (element2 != null) { | 6980 if (element != null) { |
| 6981 _resolver.override(element2, rightType); | 6981 _resolver.override(element, rightType); |
| 6982 } | 6982 } |
| 6983 } | 6983 } |
| 6984 return null; | 6984 return null; |
| 6985 } | 6985 } |
| 6986 | 6986 |
| 6987 /** | 6987 /** |
| 6988 * Record that the static type of the given node is the type of the second arg
ument to the method | 6988 * Record that the static type of the given node is the type of the second arg
ument to the method |
| 6989 * represented by the given element. | 6989 * represented by the given element. |
| 6990 * @param element the element representing the method invoked by the given nod
e | 6990 * @param element the element representing the method invoked by the given nod
e |
| 6991 */ | 6991 */ |
| 6992 Type2 computeArgumentType(ExecutableElement element) { | 6992 Type2 computeArgumentType(ExecutableElement element) { |
| 6993 if (element != null) { | 6993 if (element != null) { |
| 6994 List<ParameterElement> parameters2 = element.parameters; | 6994 List<ParameterElement> parameters = element.parameters; |
| 6995 if (parameters2 != null && parameters2.length == 2) { | 6995 if (parameters != null && parameters.length == 2) { |
| 6996 return parameters2[1].type; | 6996 return parameters[1].type; |
| 6997 } | 6997 } |
| 6998 } | 6998 } |
| 6999 return _dynamicType; | 6999 return _dynamicType; |
| 7000 } | 7000 } |
| 7001 | 7001 |
| 7002 /** | 7002 /** |
| 7003 * Compute the return type of the method or function represented by the given
element. | 7003 * Compute the return type of the method or function represented by the given
element. |
| 7004 * @param element the element representing the method or function invoked by t
he given node | 7004 * @param element the element representing the method or function invoked by t
he given node |
| 7005 * @return the return type that was computed | 7005 * @return the return type that was computed |
| 7006 */ | 7006 */ |
| 7007 Type2 computeReturnType(Element element) { | 7007 Type2 computeReturnType(Element element) { |
| 7008 if (element is PropertyAccessorElement) { | 7008 if (element is PropertyAccessorElement) { |
| 7009 FunctionType propertyType = ((element as PropertyAccessorElement)).type; | 7009 FunctionType propertyType = ((element as PropertyAccessorElement)).type; |
| 7010 if (propertyType != null) { | 7010 if (propertyType != null) { |
| 7011 Type2 returnType2 = propertyType.returnType; | 7011 Type2 returnType = propertyType.returnType; |
| 7012 if (returnType2 is InterfaceType) { | 7012 if (returnType is InterfaceType) { |
| 7013 if (identical(returnType2, _typeProvider.functionType)) { | 7013 if (identical(returnType, _typeProvider.functionType)) { |
| 7014 return _dynamicType; | 7014 return _dynamicType; |
| 7015 } | 7015 } |
| 7016 MethodElement callMethod = ((returnType2 as InterfaceType)).lookUpMeth
od(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary); | 7016 MethodElement callMethod = ((returnType as InterfaceType)).lookUpMetho
d(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary); |
| 7017 if (callMethod != null) { | 7017 if (callMethod != null) { |
| 7018 return callMethod.type.returnType; | 7018 return callMethod.type.returnType; |
| 7019 } | 7019 } |
| 7020 } else if (returnType2 is FunctionType) { | 7020 } else if (returnType is FunctionType) { |
| 7021 Type2 innerReturnType = ((returnType2 as FunctionType)).returnType; | 7021 Type2 innerReturnType = ((returnType as FunctionType)).returnType; |
| 7022 if (innerReturnType != null) { | 7022 if (innerReturnType != null) { |
| 7023 return innerReturnType; | 7023 return innerReturnType; |
| 7024 } | 7024 } |
| 7025 } else if (returnType2.isDartCoreFunction()) { | 7025 } else if (returnType.isDartCoreFunction()) { |
| 7026 return _dynamicType; | 7026 return _dynamicType; |
| 7027 } | 7027 } |
| 7028 if (returnType2 != null) { | 7028 if (returnType != null) { |
| 7029 return returnType2; | 7029 return returnType; |
| 7030 } | 7030 } |
| 7031 } | 7031 } |
| 7032 } else if (element is ExecutableElement) { | 7032 } else if (element is ExecutableElement) { |
| 7033 FunctionType type2 = ((element as ExecutableElement)).type; | 7033 FunctionType type = ((element as ExecutableElement)).type; |
| 7034 if (type2 != null) { | 7034 if (type != null) { |
| 7035 return type2.returnType; | 7035 return type.returnType; |
| 7036 } | 7036 } |
| 7037 } else if (element is VariableElement) { | 7037 } else if (element is VariableElement) { |
| 7038 Type2 variableType = ((element as VariableElement)).type; | 7038 Type2 variableType = ((element as VariableElement)).type; |
| 7039 if (variableType is FunctionType) { | 7039 if (variableType is FunctionType) { |
| 7040 return ((variableType as FunctionType)).returnType; | 7040 return ((variableType as FunctionType)).returnType; |
| 7041 } | 7041 } |
| 7042 } | 7042 } |
| 7043 return _dynamicType; | 7043 return _dynamicType; |
| 7044 } | 7044 } |
| 7045 | 7045 |
| 7046 /** | 7046 /** |
| 7047 * Given a function declaration, compute the return type of the function. The
return type of | 7047 * Given a function declaration, compute the return type of the function. The
return type of |
| 7048 * functions with a block body is {@code dynamicType}, with an expression body
it is the type of | 7048 * functions with a block body is {@code dynamicType}, with an expression body
it is the type of |
| 7049 * the expression. | 7049 * the expression. |
| 7050 * @param node the function expression whose return type is to be computed | 7050 * @param node the function expression whose return type is to be computed |
| 7051 * @return the return type that was computed | 7051 * @return the return type that was computed |
| 7052 */ | 7052 */ |
| 7053 Type2 computeReturnType2(FunctionDeclaration node) { | 7053 Type2 computeReturnType2(FunctionDeclaration node) { |
| 7054 TypeName returnType2 = node.returnType; | 7054 TypeName returnType = node.returnType; |
| 7055 if (returnType2 == null) { | 7055 if (returnType == null) { |
| 7056 return _dynamicType; | 7056 return _dynamicType; |
| 7057 } | 7057 } |
| 7058 return returnType2.type; | 7058 return returnType.type; |
| 7059 } | 7059 } |
| 7060 | 7060 |
| 7061 /** | 7061 /** |
| 7062 * Given a function expression, compute the return type of the function. The r
eturn type of | 7062 * Given a function expression, compute the return type of the function. The r
eturn type of |
| 7063 * functions with a block body is {@code dynamicType}, with an expression body
it is the type of | 7063 * functions with a block body is {@code dynamicType}, with an expression body
it is the type of |
| 7064 * the expression. | 7064 * the expression. |
| 7065 * @param node the function expression whose return type is to be computed | 7065 * @param node the function expression whose return type is to be computed |
| 7066 * @return the return type that was computed | 7066 * @return the return type that was computed |
| 7067 */ | 7067 */ |
| 7068 Type2 computeReturnType3(FunctionExpression node) { | 7068 Type2 computeReturnType3(FunctionExpression node) { |
| 7069 FunctionBody body2 = node.body; | 7069 FunctionBody body = node.body; |
| 7070 if (body2 is ExpressionFunctionBody) { | 7070 if (body is ExpressionFunctionBody) { |
| 7071 return getStaticType(((body2 as ExpressionFunctionBody)).expression); | 7071 return getStaticType(((body as ExpressionFunctionBody)).expression); |
| 7072 } | 7072 } |
| 7073 return _dynamicType; | 7073 return _dynamicType; |
| 7074 } | 7074 } |
| 7075 | 7075 |
| 7076 /** | 7076 /** |
| 7077 * Return the propagated type of the given expression if it is available, or t
he static type if | 7077 * Return the propagated type of the given expression if it is available, or t
he static type if |
| 7078 * there is no propagated type. | 7078 * there is no propagated type. |
| 7079 * @param expression the expression whose type is to be returned | 7079 * @param expression the expression whose type is to be returned |
| 7080 * @return the propagated or static type of the given expression | 7080 * @return the propagated or static type of the given expression |
| 7081 */ | 7081 */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7118 return null; | 7118 return null; |
| 7119 } | 7119 } |
| 7120 | 7120 |
| 7121 /** | 7121 /** |
| 7122 * If the given argument list contains at least one argument, and if the argum
ent is a simple | 7122 * If the given argument list contains at least one argument, and if the argum
ent is a simple |
| 7123 * string literal, return the String value of the argument. | 7123 * string literal, return the String value of the argument. |
| 7124 * @param argumentList the list of arguments from which a string value is to b
e extracted | 7124 * @param argumentList the list of arguments from which a string value is to b
e extracted |
| 7125 * @return the string specified by the first argument in the argument list | 7125 * @return the string specified by the first argument in the argument list |
| 7126 */ | 7126 */ |
| 7127 String getFirstArgumentAsString(ArgumentList argumentList) { | 7127 String getFirstArgumentAsString(ArgumentList argumentList) { |
| 7128 NodeList<Expression> arguments2 = argumentList.arguments; | 7128 NodeList<Expression> arguments = argumentList.arguments; |
| 7129 if (arguments2.length > 0) { | 7129 if (arguments.length > 0) { |
| 7130 Expression argument = arguments2[0]; | 7130 Expression argument = arguments[0]; |
| 7131 if (argument is SimpleStringLiteral) { | 7131 if (argument is SimpleStringLiteral) { |
| 7132 return ((argument as SimpleStringLiteral)).value; | 7132 return ((argument as SimpleStringLiteral)).value; |
| 7133 } | 7133 } |
| 7134 } | 7134 } |
| 7135 return null; | 7135 return null; |
| 7136 } | 7136 } |
| 7137 | 7137 |
| 7138 /** | 7138 /** |
| 7139 * If the given argument list contains at least one argument, and if the argum
ent is a simple | 7139 * If the given argument list contains at least one argument, and if the argum
ent is a simple |
| 7140 * string literal, and if the value of the argument is the name of a class def
ined within the | 7140 * string literal, and if the value of the argument is the name of a class def
ined within the |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7201 Type2 getType(PropertyAccessorElement accessor, Type2 context) { | 7201 Type2 getType(PropertyAccessorElement accessor, Type2 context) { |
| 7202 FunctionType functionType = accessor.type; | 7202 FunctionType functionType = accessor.type; |
| 7203 if (functionType == null) { | 7203 if (functionType == null) { |
| 7204 return _dynamicType; | 7204 return _dynamicType; |
| 7205 } | 7205 } |
| 7206 if (accessor.isSetter()) { | 7206 if (accessor.isSetter()) { |
| 7207 List<Type2> parameterTypes = functionType.normalParameterTypes; | 7207 List<Type2> parameterTypes = functionType.normalParameterTypes; |
| 7208 if (parameterTypes != null && parameterTypes.length > 0) { | 7208 if (parameterTypes != null && parameterTypes.length > 0) { |
| 7209 return parameterTypes[0]; | 7209 return parameterTypes[0]; |
| 7210 } | 7210 } |
| 7211 PropertyAccessorElement getter2 = accessor.variable.getter; | 7211 PropertyAccessorElement getter = accessor.variable.getter; |
| 7212 if (getter2 != null) { | 7212 if (getter != null) { |
| 7213 functionType = getter2.type; | 7213 functionType = getter.type; |
| 7214 if (functionType != null) { | 7214 if (functionType != null) { |
| 7215 return functionType.returnType; | 7215 return functionType.returnType; |
| 7216 } | 7216 } |
| 7217 } | 7217 } |
| 7218 return _dynamicType; | 7218 return _dynamicType; |
| 7219 } | 7219 } |
| 7220 Type2 returnType2 = functionType.returnType; | 7220 Type2 returnType = functionType.returnType; |
| 7221 if (returnType2 is TypeVariableType && context is InterfaceType) { | 7221 if (returnType is TypeVariableType && context is InterfaceType) { |
| 7222 InterfaceType interfaceTypeContext = (context as InterfaceType); | 7222 InterfaceType interfaceTypeContext = (context as InterfaceType); |
| 7223 List<TypeVariableElement> parameterElements = interfaceTypeContext.element
!= null ? interfaceTypeContext.element.typeVariables : null; | 7223 List<TypeVariableElement> parameterElements = interfaceTypeContext.element
!= null ? interfaceTypeContext.element.typeVariables : null; |
| 7224 if (parameterElements != null) { | 7224 if (parameterElements != null) { |
| 7225 for (int i = 0; i < parameterElements.length; i++) { | 7225 for (int i = 0; i < parameterElements.length; i++) { |
| 7226 TypeVariableElement varElt = parameterElements[i]; | 7226 TypeVariableElement varElt = parameterElements[i]; |
| 7227 if (returnType2.name == varElt.name) { | 7227 if (returnType.name == varElt.name) { |
| 7228 return interfaceTypeContext.typeArguments[i]; | 7228 return interfaceTypeContext.typeArguments[i]; |
| 7229 } | 7229 } |
| 7230 } | 7230 } |
| 7231 } | 7231 } |
| 7232 } | 7232 } |
| 7233 return returnType2; | 7233 return returnType; |
| 7234 } | 7234 } |
| 7235 | 7235 |
| 7236 /** | 7236 /** |
| 7237 * Return the type represented by the given type name. | 7237 * Return the type represented by the given type name. |
| 7238 * @param typeName the type name representing the type to be returned | 7238 * @param typeName the type name representing the type to be returned |
| 7239 * @return the type represented by the type name | 7239 * @return the type represented by the type name |
| 7240 */ | 7240 */ |
| 7241 Type2 getType2(TypeName typeName) { | 7241 Type2 getType2(TypeName typeName) { |
| 7242 Type2 type2 = typeName.type; | 7242 Type2 type = typeName.type; |
| 7243 if (type2 == null) { | 7243 if (type == null) { |
| 7244 return _dynamicType; | 7244 return _dynamicType; |
| 7245 } | 7245 } |
| 7246 return type2; | 7246 return type; |
| 7247 } | 7247 } |
| 7248 | 7248 |
| 7249 /** | 7249 /** |
| 7250 * Return {@code true} if the given library is the 'dart:html' library. | 7250 * Return {@code true} if the given library is the 'dart:html' library. |
| 7251 * @param library the library being tested | 7251 * @param library the library being tested |
| 7252 * @return {@code true} if the library is 'dart:html' | 7252 * @return {@code true} if the library is 'dart:html' |
| 7253 */ | 7253 */ |
| 7254 bool isHtmlLibrary(LibraryElement library) => library.name == "dart.dom.html"; | 7254 bool isHtmlLibrary(LibraryElement library) => library.name == "dart.dom.html"; |
| 7255 | 7255 |
| 7256 /** | 7256 /** |
| 7257 * Return {@code true} if the given node is not a type literal. | 7257 * Return {@code true} if the given node is not a type literal. |
| 7258 * @param node the node being tested | 7258 * @param node the node being tested |
| 7259 * @return {@code true} if the given node is not a type literal | 7259 * @return {@code true} if the given node is not a type literal |
| 7260 */ | 7260 */ |
| 7261 bool isNotTypeLiteral(Identifier node) { | 7261 bool isNotTypeLiteral(Identifier node) { |
| 7262 ASTNode parent2 = node.parent; | 7262 ASTNode parent = node.parent; |
| 7263 return parent2 is TypeName || (parent2 is PrefixedIdentifier && (parent2.par
ent is TypeName || identical(((parent2 as PrefixedIdentifier)).prefix, node))) |
| (parent2 is PropertyAccess && identical(((parent2 as PropertyAccess)).target,
node)) || (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInv
ocation)).target)); | 7263 return parent is TypeName || (parent is PrefixedIdentifier && (parent.parent
is TypeName || identical(((parent as PrefixedIdentifier)).prefix, node))) || (p
arent is PropertyAccess && identical(((parent as PropertyAccess)).target, node))
|| (parent is MethodInvocation && identical(node, ((parent as MethodInvocation)
).target)); |
| 7264 } | 7264 } |
| 7265 | 7265 |
| 7266 /** | 7266 /** |
| 7267 * Record that the propagated type of the given node is the given type. | 7267 * Record that the propagated type of the given node is the given type. |
| 7268 * @param expression the node whose type is to be recorded | 7268 * @param expression the node whose type is to be recorded |
| 7269 * @param type the propagated type of the node | 7269 * @param type the propagated type of the node |
| 7270 */ | 7270 */ |
| 7271 void recordPropagatedType(Expression expression, Type2 type) { | 7271 void recordPropagatedType(Expression expression, Type2 type) { |
| 7272 if (type != null && !type.isDynamic()) { | 7272 if (type != null && !type.isDynamic()) { |
| 7273 expression.propagatedType = type; | 7273 expression.propagatedType = type; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7287 } | 7287 } |
| 7288 } | 7288 } |
| 7289 | 7289 |
| 7290 /** | 7290 /** |
| 7291 * Attempts to make a better guess for the static type of the given binary exp
ression. | 7291 * Attempts to make a better guess for the static type of the given binary exp
ression. |
| 7292 * @param node the binary expression to analyze | 7292 * @param node the binary expression to analyze |
| 7293 * @param staticType the static type of the expression as resolved | 7293 * @param staticType the static type of the expression as resolved |
| 7294 * @return the better type guess, or the same static type as given | 7294 * @return the better type guess, or the same static type as given |
| 7295 */ | 7295 */ |
| 7296 Type2 refineBinaryExpressionType(BinaryExpression node, Type2 staticType) { | 7296 Type2 refineBinaryExpressionType(BinaryExpression node, Type2 staticType) { |
| 7297 sc.TokenType operator2 = node.operator.type; | 7297 sc.TokenType operator = node.operator.type; |
| 7298 if (identical(operator2, sc.TokenType.AMPERSAND_AMPERSAND) || identical(oper
ator2, sc.TokenType.BAR_BAR) || identical(operator2, sc.TokenType.EQ_EQ) || iden
tical(operator2, sc.TokenType.BANG_EQ)) { | 7298 if (identical(operator, sc.TokenType.AMPERSAND_AMPERSAND) || identical(opera
tor, sc.TokenType.BAR_BAR) || identical(operator, sc.TokenType.EQ_EQ) || identic
al(operator, sc.TokenType.BANG_EQ)) { |
| 7299 return _typeProvider.boolType; | 7299 return _typeProvider.boolType; |
| 7300 } | 7300 } |
| 7301 if (identical(operator2, sc.TokenType.MINUS) || identical(operator2, sc.Toke
nType.PERCENT) || identical(operator2, sc.TokenType.PLUS) || identical(operator2
, sc.TokenType.STAR)) { | 7301 if (identical(operator, sc.TokenType.MINUS) || identical(operator, sc.TokenT
ype.PERCENT) || identical(operator, sc.TokenType.PLUS) || identical(operator, sc
.TokenType.STAR)) { |
| 7302 Type2 doubleType2 = _typeProvider.doubleType; | 7302 Type2 doubleType = _typeProvider.doubleType; |
| 7303 if (identical(getStaticType(node.leftOperand), doubleType2) || identical(g
etStaticType(node.rightOperand), doubleType2)) { | 7303 if (identical(getStaticType(node.leftOperand), doubleType) || identical(ge
tStaticType(node.rightOperand), doubleType)) { |
| 7304 return doubleType2; | 7304 return doubleType; |
| 7305 } | 7305 } |
| 7306 } | 7306 } |
| 7307 if (identical(operator2, sc.TokenType.MINUS) || identical(operator2, sc.Toke
nType.PERCENT) || identical(operator2, sc.TokenType.PLUS) || identical(operator2
, sc.TokenType.STAR) || identical(operator2, sc.TokenType.TILDE_SLASH)) { | 7307 if (identical(operator, sc.TokenType.MINUS) || identical(operator, sc.TokenT
ype.PERCENT) || identical(operator, sc.TokenType.PLUS) || identical(operator, sc
.TokenType.STAR) || identical(operator, sc.TokenType.TILDE_SLASH)) { |
| 7308 Type2 intType2 = _typeProvider.intType; | 7308 Type2 intType = _typeProvider.intType; |
| 7309 if (identical(getStaticType(node.leftOperand), intType2) && identical(getS
taticType(node.rightOperand), intType2)) { | 7309 if (identical(getStaticType(node.leftOperand), intType) && identical(getSt
aticType(node.rightOperand), intType)) { |
| 7310 staticType = intType2; | 7310 staticType = intType; |
| 7311 } | 7311 } |
| 7312 } | 7312 } |
| 7313 return staticType; | 7313 return staticType; |
| 7314 } | 7314 } |
| 7315 | 7315 |
| 7316 /** | 7316 /** |
| 7317 * Set the return type and parameter type information for the given function t
ype based on the | 7317 * Set the return type and parameter type information for the given function t
ype based on the |
| 7318 * given return type and parameter elements. | 7318 * given return type and parameter elements. |
| 7319 * @param functionType the function type to be filled in | 7319 * @param functionType the function type to be filled in |
| 7320 * @param returnType the return type of the function, or {@code null} if no ty
pe was declared | 7320 * @param returnType the return type of the function, or {@code null} if no ty
pe was declared |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 /** | 7479 /** |
| 7480 * Return a map from the elements for the variables in the given list that hav
e their types | 7480 * Return a map from the elements for the variables in the given list that hav
e their types |
| 7481 * overridden to the overriding type. | 7481 * overridden to the overriding type. |
| 7482 * @param variableList the list of variables whose overriding types are to be
captured | 7482 * @param variableList the list of variables whose overriding types are to be
captured |
| 7483 * @return a table mapping elements to their overriding types | 7483 * @return a table mapping elements to their overriding types |
| 7484 */ | 7484 */ |
| 7485 Map<Element, Type2> captureOverrides(VariableDeclarationList variableList) { | 7485 Map<Element, Type2> captureOverrides(VariableDeclarationList variableList) { |
| 7486 Map<Element, Type2> overrides = new Map<Element, Type2>(); | 7486 Map<Element, Type2> overrides = new Map<Element, Type2>(); |
| 7487 if (variableList.isConst() || variableList.isFinal()) { | 7487 if (variableList.isConst() || variableList.isFinal()) { |
| 7488 for (VariableDeclaration variable in variableList.variables) { | 7488 for (VariableDeclaration variable in variableList.variables) { |
| 7489 Element element2 = variable.element; | 7489 Element element = variable.element; |
| 7490 if (element2 != null) { | 7490 if (element != null) { |
| 7491 Type2 type = _overridenTypes[element2]; | 7491 Type2 type = _overridenTypes[element]; |
| 7492 if (type != null) { | 7492 if (type != null) { |
| 7493 overrides[element2] = type; | 7493 overrides[element] = type; |
| 7494 } | 7494 } |
| 7495 } | 7495 } |
| 7496 } | 7496 } |
| 7497 } | 7497 } |
| 7498 return overrides; | 7498 return overrides; |
| 7499 } | 7499 } |
| 7500 | 7500 |
| 7501 /** | 7501 /** |
| 7502 * Return the overridden type of the given element, or {@code null} if the typ
e of the element | 7502 * Return the overridden type of the given element, or {@code null} if the typ
e of the element |
| 7503 * has not been overridden. | 7503 * has not been overridden. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7793 SimpleIdentifier exception = node.exceptionParameter; | 7793 SimpleIdentifier exception = node.exceptionParameter; |
| 7794 if (exception != null) { | 7794 if (exception != null) { |
| 7795 TypeName exceptionTypeName = node.exceptionType; | 7795 TypeName exceptionTypeName = node.exceptionType; |
| 7796 Type2 exceptionType; | 7796 Type2 exceptionType; |
| 7797 if (exceptionTypeName == null) { | 7797 if (exceptionTypeName == null) { |
| 7798 exceptionType = typeProvider.objectType; | 7798 exceptionType = typeProvider.objectType; |
| 7799 } else { | 7799 } else { |
| 7800 exceptionType = getType3(exceptionTypeName); | 7800 exceptionType = getType3(exceptionTypeName); |
| 7801 } | 7801 } |
| 7802 recordType(exception, exceptionType); | 7802 recordType(exception, exceptionType); |
| 7803 Element element2 = exception.element; | 7803 Element element = exception.element; |
| 7804 if (element2 is VariableElementImpl) { | 7804 if (element is VariableElementImpl) { |
| 7805 ((element2 as VariableElementImpl)).type = exceptionType; | 7805 ((element as VariableElementImpl)).type = exceptionType; |
| 7806 } else { | 7806 } else { |
| 7807 } | 7807 } |
| 7808 } | 7808 } |
| 7809 SimpleIdentifier stackTrace = node.stackTraceParameter; | 7809 SimpleIdentifier stackTrace = node.stackTraceParameter; |
| 7810 if (stackTrace != null) { | 7810 if (stackTrace != null) { |
| 7811 recordType(stackTrace, typeProvider.stackTraceType); | 7811 recordType(stackTrace, typeProvider.stackTraceType); |
| 7812 } | 7812 } |
| 7813 return null; | 7813 return null; |
| 7814 } | 7814 } |
| 7815 Object visitClassDeclaration(ClassDeclaration node) { | 7815 Object visitClassDeclaration(ClassDeclaration node) { |
| 7816 _hasReferenceToSuper = false; | 7816 _hasReferenceToSuper = false; |
| 7817 super.visitClassDeclaration(node); | 7817 super.visitClassDeclaration(node); |
| 7818 ClassElementImpl classElement = getClassElement(node.name); | 7818 ClassElementImpl classElement = getClassElement(node.name); |
| 7819 InterfaceType superclassType = null; | 7819 InterfaceType superclassType = null; |
| 7820 ExtendsClause extendsClause2 = node.extendsClause; | 7820 ExtendsClause extendsClause = node.extendsClause; |
| 7821 if (extendsClause2 != null) { | 7821 if (extendsClause != null) { |
| 7822 ErrorCode errorCode = node.withClause == null ? CompileTimeErrorCode.EXTEN
DS_NON_CLASS : CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS; | 7822 ErrorCode errorCode = node.withClause == null ? CompileTimeErrorCode.EXTEN
DS_NON_CLASS : CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS; |
| 7823 superclassType = resolveType(extendsClause2.superclass, errorCode); | 7823 superclassType = resolveType(extendsClause.superclass, errorCode); |
| 7824 if (superclassType != typeProvider.objectType) { | 7824 if (superclassType != typeProvider.objectType) { |
| 7825 classElement.validMixin = false; | 7825 classElement.validMixin = false; |
| 7826 } | 7826 } |
| 7827 } | 7827 } |
| 7828 if (classElement != null) { | 7828 if (classElement != null) { |
| 7829 if (superclassType == null) { | 7829 if (superclassType == null) { |
| 7830 InterfaceType objectType2 = typeProvider.objectType; | 7830 InterfaceType objectType = typeProvider.objectType; |
| 7831 if (classElement.type != objectType2) { | 7831 if (classElement.type != objectType) { |
| 7832 superclassType = objectType2; | 7832 superclassType = objectType; |
| 7833 } | 7833 } |
| 7834 } | 7834 } |
| 7835 classElement.supertype = superclassType; | 7835 classElement.supertype = superclassType; |
| 7836 classElement.hasReferenceToSuper2 = _hasReferenceToSuper; | 7836 classElement.hasReferenceToSuper2 = _hasReferenceToSuper; |
| 7837 } | 7837 } |
| 7838 resolve(classElement, node.withClause, node.implementsClause); | 7838 resolve(classElement, node.withClause, node.implementsClause); |
| 7839 return null; | 7839 return null; |
| 7840 } | 7840 } |
| 7841 Object visitClassTypeAlias(ClassTypeAlias node) { | 7841 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 7842 super.visitClassTypeAlias(node); | 7842 super.visitClassTypeAlias(node); |
| 7843 ClassElementImpl classElement = getClassElement(node.name); | 7843 ClassElementImpl classElement = getClassElement(node.name); |
| 7844 InterfaceType superclassType = resolveType(node.superclass, CompileTimeError
Code.MIXIN_WITH_NON_CLASS_SUPERCLASS); | 7844 InterfaceType superclassType = resolveType(node.superclass, CompileTimeError
Code.MIXIN_WITH_NON_CLASS_SUPERCLASS); |
| 7845 if (superclassType == null) { | 7845 if (superclassType == null) { |
| 7846 superclassType = typeProvider.objectType; | 7846 superclassType = typeProvider.objectType; |
| 7847 } | 7847 } |
| 7848 if (classElement != null && superclassType != null) { | 7848 if (classElement != null && superclassType != null) { |
| 7849 classElement.supertype = superclassType; | 7849 classElement.supertype = superclassType; |
| 7850 } | 7850 } |
| 7851 resolve(classElement, node.withClause, node.implementsClause); | 7851 resolve(classElement, node.withClause, node.implementsClause); |
| 7852 return null; | 7852 return null; |
| 7853 } | 7853 } |
| 7854 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 7854 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 7855 super.visitConstructorDeclaration(node); | 7855 super.visitConstructorDeclaration(node); |
| 7856 ExecutableElementImpl element2 = node.element as ExecutableElementImpl; | 7856 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 7857 FunctionTypeImpl type = new FunctionTypeImpl.con1(element2); | 7857 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 7858 setTypeInformation(type, null, element2.parameters); | 7858 setTypeInformation(type, null, element.parameters); |
| 7859 type.returnType = ((element2.enclosingElement as ClassElement)).type; | 7859 type.returnType = ((element.enclosingElement as ClassElement)).type; |
| 7860 element2.type = type; | 7860 element.type = type; |
| 7861 return null; | 7861 return null; |
| 7862 } | 7862 } |
| 7863 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 7863 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 7864 super.visitDeclaredIdentifier(node); | 7864 super.visitDeclaredIdentifier(node); |
| 7865 Type2 declaredType; | 7865 Type2 declaredType; |
| 7866 TypeName typeName = node.type; | 7866 TypeName typeName = node.type; |
| 7867 if (typeName == null) { | 7867 if (typeName == null) { |
| 7868 declaredType = _dynamicType; | 7868 declaredType = _dynamicType; |
| 7869 } else { | 7869 } else { |
| 7870 declaredType = getType3(typeName); | 7870 declaredType = getType3(typeName); |
| 7871 } | 7871 } |
| 7872 LocalVariableElementImpl element2 = node.element as LocalVariableElementImpl
; | 7872 LocalVariableElementImpl element = node.element as LocalVariableElementImpl; |
| 7873 element2.type = declaredType; | 7873 element.type = declaredType; |
| 7874 return null; | 7874 return null; |
| 7875 } | 7875 } |
| 7876 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 7876 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 7877 super.visitDefaultFormalParameter(node); | 7877 super.visitDefaultFormalParameter(node); |
| 7878 return null; | 7878 return null; |
| 7879 } | 7879 } |
| 7880 Object visitFieldFormalParameter(FieldFormalParameter node) { | 7880 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 7881 super.visitFieldFormalParameter(node); | 7881 super.visitFieldFormalParameter(node); |
| 7882 Element element2 = node.identifier.element; | 7882 Element element = node.identifier.element; |
| 7883 if (element2 is ParameterElementImpl) { | 7883 if (element is ParameterElementImpl) { |
| 7884 ParameterElementImpl parameter = element2 as ParameterElementImpl; | 7884 ParameterElementImpl parameter = element as ParameterElementImpl; |
| 7885 Type2 type; | 7885 Type2 type; |
| 7886 TypeName typeName = node.type; | 7886 TypeName typeName = node.type; |
| 7887 if (typeName == null) { | 7887 if (typeName == null) { |
| 7888 type = _dynamicType; | 7888 type = _dynamicType; |
| 7889 } else { | 7889 } else { |
| 7890 type = getType3(typeName); | 7890 type = getType3(typeName); |
| 7891 } | 7891 } |
| 7892 parameter.type = type; | 7892 parameter.type = type; |
| 7893 } else { | 7893 } else { |
| 7894 } | 7894 } |
| 7895 return null; | 7895 return null; |
| 7896 } | 7896 } |
| 7897 Object visitFunctionDeclaration(FunctionDeclaration node) { | 7897 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 7898 super.visitFunctionDeclaration(node); | 7898 super.visitFunctionDeclaration(node); |
| 7899 ExecutableElementImpl element2 = node.element as ExecutableElementImpl; | 7899 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 7900 FunctionTypeImpl type = new FunctionTypeImpl.con1(element2); | 7900 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 7901 setTypeInformation(type, node.returnType, element2.parameters); | 7901 setTypeInformation(type, node.returnType, element.parameters); |
| 7902 element2.type = type; | 7902 element.type = type; |
| 7903 return null; | 7903 return null; |
| 7904 } | 7904 } |
| 7905 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 7905 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 7906 super.visitFunctionTypeAlias(node); | 7906 super.visitFunctionTypeAlias(node); |
| 7907 FunctionTypeAliasElementImpl element2 = node.element as FunctionTypeAliasEle
mentImpl; | 7907 FunctionTypeAliasElementImpl element = node.element as FunctionTypeAliasElem
entImpl; |
| 7908 FunctionTypeImpl type2 = element2.type as FunctionTypeImpl; | 7908 FunctionTypeImpl type = element.type as FunctionTypeImpl; |
| 7909 setTypeInformation(type2, node.returnType, element2.parameters); | 7909 setTypeInformation(type, node.returnType, element.parameters); |
| 7910 return null; | 7910 return null; |
| 7911 } | 7911 } |
| 7912 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 7912 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 7913 super.visitFunctionTypedFormalParameter(node); | 7913 super.visitFunctionTypedFormalParameter(node); |
| 7914 ParameterElementImpl element2 = node.identifier.element as ParameterElementI
mpl; | 7914 ParameterElementImpl element = node.identifier.element as ParameterElementIm
pl; |
| 7915 AnonymousFunctionTypeImpl type = new AnonymousFunctionTypeImpl(); | 7915 AnonymousFunctionTypeImpl type = new AnonymousFunctionTypeImpl(); |
| 7916 List<ParameterElement> parameters2 = getElements(node.parameters); | 7916 List<ParameterElement> parameters = getElements(node.parameters); |
| 7917 setTypeInformation(type, node.returnType, parameters2); | 7917 setTypeInformation(type, node.returnType, parameters); |
| 7918 type.baseParameters = parameters2; | 7918 type.baseParameters = parameters; |
| 7919 element2.type = type; | 7919 element.type = type; |
| 7920 return null; | 7920 return null; |
| 7921 } | 7921 } |
| 7922 Object visitMethodDeclaration(MethodDeclaration node) { | 7922 Object visitMethodDeclaration(MethodDeclaration node) { |
| 7923 super.visitMethodDeclaration(node); | 7923 super.visitMethodDeclaration(node); |
| 7924 ExecutableElementImpl element2 = node.element as ExecutableElementImpl; | 7924 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 7925 FunctionTypeImpl type = new FunctionTypeImpl.con1(element2); | 7925 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 7926 setTypeInformation(type, node.returnType, element2.parameters); | 7926 setTypeInformation(type, node.returnType, element.parameters); |
| 7927 element2.type = type; | 7927 element.type = type; |
| 7928 if (element2 is PropertyAccessorElement) { | 7928 if (element is PropertyAccessorElement) { |
| 7929 PropertyAccessorElement accessor = element2 as PropertyAccessorElement; | 7929 PropertyAccessorElement accessor = element as PropertyAccessorElement; |
| 7930 PropertyInducingElementImpl variable2 = accessor.variable as PropertyInduc
ingElementImpl; | 7930 PropertyInducingElementImpl variable = accessor.variable as PropertyInduci
ngElementImpl; |
| 7931 if (accessor.isGetter()) { | 7931 if (accessor.isGetter()) { |
| 7932 variable2.type = type.returnType; | 7932 variable.type = type.returnType; |
| 7933 } else if (variable2.type == null) { | 7933 } else if (variable.type == null) { |
| 7934 List<Type2> parameterTypes = type.normalParameterTypes; | 7934 List<Type2> parameterTypes = type.normalParameterTypes; |
| 7935 if (parameterTypes != null && parameterTypes.length > 0) { | 7935 if (parameterTypes != null && parameterTypes.length > 0) { |
| 7936 variable2.type = parameterTypes[0]; | 7936 variable.type = parameterTypes[0]; |
| 7937 } | 7937 } |
| 7938 } | 7938 } |
| 7939 } | 7939 } |
| 7940 return null; | 7940 return null; |
| 7941 } | 7941 } |
| 7942 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 7942 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 7943 super.visitSimpleFormalParameter(node); | 7943 super.visitSimpleFormalParameter(node); |
| 7944 Type2 declaredType; | 7944 Type2 declaredType; |
| 7945 TypeName typeName = node.type; | 7945 TypeName typeName = node.type; |
| 7946 if (typeName == null) { | 7946 if (typeName == null) { |
| 7947 declaredType = _dynamicType; | 7947 declaredType = _dynamicType; |
| 7948 } else { | 7948 } else { |
| 7949 declaredType = getType3(typeName); | 7949 declaredType = getType3(typeName); |
| 7950 } | 7950 } |
| 7951 Element element2 = node.identifier.element; | 7951 Element element = node.identifier.element; |
| 7952 if (element2 is ParameterElement) { | 7952 if (element is ParameterElement) { |
| 7953 ((element2 as ParameterElementImpl)).type = declaredType; | 7953 ((element as ParameterElementImpl)).type = declaredType; |
| 7954 } else { | 7954 } else { |
| 7955 } | 7955 } |
| 7956 return null; | 7956 return null; |
| 7957 } | 7957 } |
| 7958 Object visitSuperExpression(SuperExpression node) { | 7958 Object visitSuperExpression(SuperExpression node) { |
| 7959 _hasReferenceToSuper = true; | 7959 _hasReferenceToSuper = true; |
| 7960 return super.visitSuperExpression(node); | 7960 return super.visitSuperExpression(node); |
| 7961 } | 7961 } |
| 7962 Object visitTypeName(TypeName node) { | 7962 Object visitTypeName(TypeName node) { |
| 7963 super.visitTypeName(node); | 7963 super.visitTypeName(node); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7974 return null; | 7974 return null; |
| 7975 } | 7975 } |
| 7976 VoidTypeImpl voidType = VoidTypeImpl.instance; | 7976 VoidTypeImpl voidType = VoidTypeImpl.instance; |
| 7977 if (typeName.name == voidType.name) { | 7977 if (typeName.name == voidType.name) { |
| 7978 if (argumentList != null) { | 7978 if (argumentList != null) { |
| 7979 } | 7979 } |
| 7980 typeName.staticType = voidType; | 7980 typeName.staticType = voidType; |
| 7981 node.type = voidType; | 7981 node.type = voidType; |
| 7982 return null; | 7982 return null; |
| 7983 } | 7983 } |
| 7984 ASTNode parent2 = node.parent; | 7984 ASTNode parent = node.parent; |
| 7985 if (typeName is PrefixedIdentifier && parent2 is ConstructorName && argume
ntList == null) { | 7985 if (typeName is PrefixedIdentifier && parent is ConstructorName && argumen
tList == null) { |
| 7986 ConstructorName name = parent2 as ConstructorName; | 7986 ConstructorName name = parent as ConstructorName; |
| 7987 if (name.name == null) { | 7987 if (name.name == null) { |
| 7988 SimpleIdentifier prefix2 = ((typeName as PrefixedIdentifier)).prefix; | 7988 SimpleIdentifier prefix = ((typeName as PrefixedIdentifier)).prefix; |
| 7989 element = nameScope.lookup(prefix2, definingLibrary); | 7989 element = nameScope.lookup(prefix, definingLibrary); |
| 7990 if (element is PrefixElement) { | 7990 if (element is PrefixElement) { |
| 7991 return null; | 7991 return null; |
| 7992 } else if (element != null) { | 7992 } else if (element != null) { |
| 7993 name.name = ((typeName as PrefixedIdentifier)).identifier; | 7993 name.name = ((typeName as PrefixedIdentifier)).identifier; |
| 7994 name.period = ((typeName as PrefixedIdentifier)).period; | 7994 name.period = ((typeName as PrefixedIdentifier)).period; |
| 7995 node.name = prefix2; | 7995 node.name = prefix; |
| 7996 typeName = prefix2; | 7996 typeName = prefix; |
| 7997 } | 7997 } |
| 7998 } | 7998 } |
| 7999 } | 7999 } |
| 8000 } | 8000 } |
| 8001 bool elementValid = element is! MultiplyDefinedElement; | 8001 bool elementValid = element is! MultiplyDefinedElement; |
| 8002 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation
Expression(node)) { | 8002 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation
Expression(node)) { |
| 8003 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); | 8003 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); |
| 8004 InstanceCreationExpression creation = node.parent.parent as InstanceCreati
onExpression; | 8004 InstanceCreationExpression creation = node.parent.parent as InstanceCreati
onExpression; |
| 8005 if (creation.isConst()) { | 8005 if (creation.isConst()) { |
| 8006 if (element == null) { | 8006 if (element == null) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8058 node.type = type; | 8058 node.type = type; |
| 8059 } | 8059 } |
| 8060 } else { | 8060 } else { |
| 8061 if (isTypeNameInCatchClause(node)) { | 8061 if (isTypeNameInCatchClause(node)) { |
| 8062 reportError(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeN
ame.name]); | 8062 reportError(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeN
ame.name]); |
| 8063 } else if (isTypeNameInAsExpression(node)) { | 8063 } else if (isTypeNameInAsExpression(node)) { |
| 8064 reportError(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name
]); | 8064 reportError(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name
]); |
| 8065 } else if (isTypeNameInIsExpression(node)) { | 8065 } else if (isTypeNameInIsExpression(node)) { |
| 8066 reportError(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.na
me]); | 8066 reportError(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.na
me]); |
| 8067 } else { | 8067 } else { |
| 8068 ASTNode parent3 = typeName.parent; | 8068 ASTNode parent = typeName.parent; |
| 8069 while (parent3 is TypeName) { | 8069 while (parent is TypeName) { |
| 8070 parent3 = parent3.parent; | 8070 parent = parent.parent; |
| 8071 } | 8071 } |
| 8072 if (parent3 is ExtendsClause || parent3 is ImplementsClause || parent3 i
s WithClause || parent3 is ClassTypeAlias) { | 8072 if (parent is ExtendsClause || parent is ImplementsClause || parent is W
ithClause || parent is ClassTypeAlias) { |
| 8073 } else { | 8073 } else { |
| 8074 reportError(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); | 8074 reportError(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); |
| 8075 } | 8075 } |
| 8076 } | 8076 } |
| 8077 setElement(typeName, _dynamicType.element); | 8077 setElement(typeName, _dynamicType.element); |
| 8078 typeName.staticType = _dynamicType; | 8078 typeName.staticType = _dynamicType; |
| 8079 node.type = _dynamicType; | 8079 node.type = _dynamicType; |
| 8080 return null; | 8080 return null; |
| 8081 } | 8081 } |
| 8082 if (argumentList != null) { | 8082 if (argumentList != null) { |
| 8083 NodeList<TypeName> arguments2 = argumentList.arguments; | 8083 NodeList<TypeName> arguments = argumentList.arguments; |
| 8084 int argumentCount = arguments2.length; | 8084 int argumentCount = arguments.length; |
| 8085 List<Type2> parameters = getTypeArguments(type); | 8085 List<Type2> parameters = getTypeArguments(type); |
| 8086 int parameterCount = parameters.length; | 8086 int parameterCount = parameters.length; |
| 8087 int count = Math.min(argumentCount, parameterCount); | 8087 int count = Math.min(argumentCount, parameterCount); |
| 8088 List<Type2> typeArguments = new List<Type2>(); | 8088 List<Type2> typeArguments = new List<Type2>(); |
| 8089 for (int i = 0; i < count; i++) { | 8089 for (int i = 0; i < count; i++) { |
| 8090 Type2 argumentType = getType3(arguments2[i]); | 8090 Type2 argumentType = getType3(arguments[i]); |
| 8091 if (argumentType != null) { | 8091 if (argumentType != null) { |
| 8092 typeArguments.add(argumentType); | 8092 typeArguments.add(argumentType); |
| 8093 } | 8093 } |
| 8094 } | 8094 } |
| 8095 if (argumentCount != parameterCount) { | 8095 if (argumentCount != parameterCount) { |
| 8096 reportError(getInvalidTypeParametersErrorCode(node), node, [typeName.nam
e, parameterCount, argumentCount]); | 8096 reportError(getInvalidTypeParametersErrorCode(node), node, [typeName.nam
e, parameterCount, argumentCount]); |
| 8097 } | 8097 } |
| 8098 argumentCount = typeArguments.length; | 8098 argumentCount = typeArguments.length; |
| 8099 if (argumentCount < parameterCount) { | 8099 if (argumentCount < parameterCount) { |
| 8100 for (int i = argumentCount; i < parameterCount; i++) { | 8100 for (int i = argumentCount; i < parameterCount; i++) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 8127 } | 8127 } |
| 8128 Object visitVariableDeclaration(VariableDeclaration node) { | 8128 Object visitVariableDeclaration(VariableDeclaration node) { |
| 8129 super.visitVariableDeclaration(node); | 8129 super.visitVariableDeclaration(node); |
| 8130 Type2 declaredType; | 8130 Type2 declaredType; |
| 8131 TypeName typeName = ((node.parent as VariableDeclarationList)).type; | 8131 TypeName typeName = ((node.parent as VariableDeclarationList)).type; |
| 8132 if (typeName == null) { | 8132 if (typeName == null) { |
| 8133 declaredType = _dynamicType; | 8133 declaredType = _dynamicType; |
| 8134 } else { | 8134 } else { |
| 8135 declaredType = getType3(typeName); | 8135 declaredType = getType3(typeName); |
| 8136 } | 8136 } |
| 8137 Element element2 = node.name.element; | 8137 Element element = node.name.element; |
| 8138 if (element2 is VariableElement) { | 8138 if (element is VariableElement) { |
| 8139 ((element2 as VariableElementImpl)).type = declaredType; | 8139 ((element as VariableElementImpl)).type = declaredType; |
| 8140 if (element2 is PropertyInducingElement) { | 8140 if (element is PropertyInducingElement) { |
| 8141 PropertyInducingElement variableElement = element2 as PropertyInducingEl
ement; | 8141 PropertyInducingElement variableElement = element as PropertyInducingEle
ment; |
| 8142 PropertyAccessorElementImpl getter2 = variableElement.getter as Property
AccessorElementImpl; | 8142 PropertyAccessorElementImpl getter = variableElement.getter as PropertyA
ccessorElementImpl; |
| 8143 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter2); | 8143 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
| 8144 getterType.returnType = declaredType; | 8144 getterType.returnType = declaredType; |
| 8145 getter2.type = getterType; | 8145 getter.type = getterType; |
| 8146 PropertyAccessorElementImpl setter2 = variableElement.setter as Property
AccessorElementImpl; | 8146 PropertyAccessorElementImpl setter = variableElement.setter as PropertyA
ccessorElementImpl; |
| 8147 if (setter2 != null) { | 8147 if (setter != null) { |
| 8148 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter2); | 8148 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter); |
| 8149 setterType.returnType = VoidTypeImpl.instance; | 8149 setterType.returnType = VoidTypeImpl.instance; |
| 8150 setterType.normalParameterTypes = <Type2> [declaredType]; | 8150 setterType.normalParameterTypes = <Type2> [declaredType]; |
| 8151 setter2.type = setterType; | 8151 setter.type = setterType; |
| 8152 } | 8152 } |
| 8153 } | 8153 } |
| 8154 } else { | 8154 } else { |
| 8155 } | 8155 } |
| 8156 return null; | 8156 return null; |
| 8157 } | 8157 } |
| 8158 | 8158 |
| 8159 /** | 8159 /** |
| 8160 * Return the class element that represents the class whose name was provided. | 8160 * Return the class element that represents the class whose name was provided. |
| 8161 * @param identifier the name from the declaration of a class | 8161 * @param identifier the name from the declaration of a class |
| 8162 * @return the class element that represents the class | 8162 * @return the class element that represents the class |
| 8163 */ | 8163 */ |
| 8164 ClassElementImpl getClassElement(SimpleIdentifier identifier) { | 8164 ClassElementImpl getClassElement(SimpleIdentifier identifier) { |
| 8165 if (identifier == null) { | 8165 if (identifier == null) { |
| 8166 return null; | 8166 return null; |
| 8167 } | 8167 } |
| 8168 Element element2 = identifier.element; | 8168 Element element = identifier.element; |
| 8169 if (element2 is! ClassElementImpl) { | 8169 if (element is! ClassElementImpl) { |
| 8170 return null; | 8170 return null; |
| 8171 } | 8171 } |
| 8172 return element2 as ClassElementImpl; | 8172 return element as ClassElementImpl; |
| 8173 } | 8173 } |
| 8174 | 8174 |
| 8175 /** | 8175 /** |
| 8176 * Return an array containing all of the elements associated with the paramete
rs in the given | 8176 * Return an array containing all of the elements associated with the paramete
rs in the given |
| 8177 * list. | 8177 * list. |
| 8178 * @param parameterList the list of parameters whose elements are to be return
ed | 8178 * @param parameterList the list of parameters whose elements are to be return
ed |
| 8179 * @return the elements associated with the parameters | 8179 * @return the elements associated with the parameters |
| 8180 */ | 8180 */ |
| 8181 List<ParameterElement> getElements(FormalParameterList parameterList) { | 8181 List<ParameterElement> getElements(FormalParameterList parameterList) { |
| 8182 List<ParameterElement> elements = new List<ParameterElement>(); | 8182 List<ParameterElement> elements = new List<ParameterElement>(); |
| 8183 for (FormalParameter parameter in parameterList.parameters) { | 8183 for (FormalParameter parameter in parameterList.parameters) { |
| 8184 ParameterElement element2 = parameter.identifier.element as ParameterEleme
nt; | 8184 ParameterElement element = parameter.identifier.element as ParameterElemen
t; |
| 8185 if (element2 != null) { | 8185 if (element != null) { |
| 8186 elements.add(element2); | 8186 elements.add(element); |
| 8187 } | 8187 } |
| 8188 } | 8188 } |
| 8189 return new List.from(elements); | 8189 return new List.from(elements); |
| 8190 } | 8190 } |
| 8191 | 8191 |
| 8192 /** | 8192 /** |
| 8193 * The number of type arguments in the given type name does not match the numb
er of parameters in | 8193 * The number of type arguments in the given type name does not match the numb
er of parameters in |
| 8194 * the corresponding class element. Return the error code that should be used
to report this | 8194 * the corresponding class element. Return the error code that should be used
to report this |
| 8195 * error. | 8195 * error. |
| 8196 * @param node the type name with the wrong number of type arguments | 8196 * @param node the type name with the wrong number of type arguments |
| 8197 * @return the error code that should be used to report that the wrong number
of type arguments | 8197 * @return the error code that should be used to report that the wrong number
of type arguments |
| 8198 * were provided | 8198 * were provided |
| 8199 */ | 8199 */ |
| 8200 ErrorCode getInvalidTypeParametersErrorCode(TypeName node) { | 8200 ErrorCode getInvalidTypeParametersErrorCode(TypeName node) { |
| 8201 ASTNode parent2 = node.parent; | 8201 ASTNode parent = node.parent; |
| 8202 if (parent2 is ConstructorName) { | 8202 if (parent is ConstructorName) { |
| 8203 parent2 = parent2.parent; | 8203 parent = parent.parent; |
| 8204 if (parent2 is InstanceCreationExpression) { | 8204 if (parent is InstanceCreationExpression) { |
| 8205 if (((parent2 as InstanceCreationExpression)).isConst()) { | 8205 if (((parent as InstanceCreationExpression)).isConst()) { |
| 8206 return CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS; | 8206 return CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS; |
| 8207 } else { | 8207 } else { |
| 8208 return CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS; | 8208 return CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS; |
| 8209 } | 8209 } |
| 8210 } | 8210 } |
| 8211 } | 8211 } |
| 8212 return StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS; | 8212 return StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS; |
| 8213 } | 8213 } |
| 8214 | 8214 |
| 8215 /** | 8215 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8230 } | 8230 } |
| 8231 return type; | 8231 return type; |
| 8232 } | 8232 } |
| 8233 | 8233 |
| 8234 /** | 8234 /** |
| 8235 * Return the type represented by the given type name. | 8235 * Return the type represented by the given type name. |
| 8236 * @param typeName the type name representing the type to be returned | 8236 * @param typeName the type name representing the type to be returned |
| 8237 * @return the type represented by the type name | 8237 * @return the type represented by the type name |
| 8238 */ | 8238 */ |
| 8239 Type2 getType3(TypeName typeName) { | 8239 Type2 getType3(TypeName typeName) { |
| 8240 Type2 type2 = typeName.type; | 8240 Type2 type = typeName.type; |
| 8241 if (type2 == null) { | 8241 if (type == null) { |
| 8242 return _dynamicType; | 8242 return _dynamicType; |
| 8243 } | 8243 } |
| 8244 return type2; | 8244 return type; |
| 8245 } | 8245 } |
| 8246 | 8246 |
| 8247 /** | 8247 /** |
| 8248 * Return the type arguments associated with the given type. | 8248 * Return the type arguments associated with the given type. |
| 8249 * @param type the type whole type arguments are to be returned | 8249 * @param type the type whole type arguments are to be returned |
| 8250 * @return the type arguments associated with the given type | 8250 * @return the type arguments associated with the given type |
| 8251 */ | 8251 */ |
| 8252 List<Type2> getTypeArguments(Type2 type) { | 8252 List<Type2> getTypeArguments(Type2 type) { |
| 8253 if (type is InterfaceType) { | 8253 if (type is InterfaceType) { |
| 8254 return ((type as InterfaceType)).typeArguments; | 8254 return ((type as InterfaceType)).typeArguments; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8270 return ((typeName as PrefixedIdentifier)).identifier; | 8270 return ((typeName as PrefixedIdentifier)).identifier; |
| 8271 } | 8271 } |
| 8272 } | 8272 } |
| 8273 | 8273 |
| 8274 /** | 8274 /** |
| 8275 * Checks if the given type name is used as the type in an as expression. | 8275 * Checks if the given type name is used as the type in an as expression. |
| 8276 * @param typeName the type name to analyzer | 8276 * @param typeName the type name to analyzer |
| 8277 * @return {@code true} if the given type name is used as the type in an as ex
pression | 8277 * @return {@code true} if the given type name is used as the type in an as ex
pression |
| 8278 */ | 8278 */ |
| 8279 bool isTypeNameInAsExpression(TypeName typeName) { | 8279 bool isTypeNameInAsExpression(TypeName typeName) { |
| 8280 ASTNode parent2 = typeName.parent; | 8280 ASTNode parent = typeName.parent; |
| 8281 if (parent2 is AsExpression) { | 8281 if (parent is AsExpression) { |
| 8282 AsExpression asExpression = parent2 as AsExpression; | 8282 AsExpression asExpression = parent as AsExpression; |
| 8283 return identical(asExpression.type, typeName); | 8283 return identical(asExpression.type, typeName); |
| 8284 } | 8284 } |
| 8285 return false; | 8285 return false; |
| 8286 } | 8286 } |
| 8287 | 8287 |
| 8288 /** | 8288 /** |
| 8289 * Checks if the given type name is used as the exception type in a catch clau
se. | 8289 * Checks if the given type name is used as the exception type in a catch clau
se. |
| 8290 * @param typeName the type name to analyzer | 8290 * @param typeName the type name to analyzer |
| 8291 * @return {@code true} if the given type name is used as the exception type i
n a catch clause | 8291 * @return {@code true} if the given type name is used as the exception type i
n a catch clause |
| 8292 */ | 8292 */ |
| 8293 bool isTypeNameInCatchClause(TypeName typeName) { | 8293 bool isTypeNameInCatchClause(TypeName typeName) { |
| 8294 ASTNode parent2 = typeName.parent; | 8294 ASTNode parent = typeName.parent; |
| 8295 if (parent2 is CatchClause) { | 8295 if (parent is CatchClause) { |
| 8296 CatchClause catchClause = parent2 as CatchClause; | 8296 CatchClause catchClause = parent as CatchClause; |
| 8297 return identical(catchClause.exceptionType, typeName); | 8297 return identical(catchClause.exceptionType, typeName); |
| 8298 } | 8298 } |
| 8299 return false; | 8299 return false; |
| 8300 } | 8300 } |
| 8301 | 8301 |
| 8302 /** | 8302 /** |
| 8303 * Checks if the given type name is used as the type in an instance creation e
xpression. | 8303 * Checks if the given type name is used as the type in an instance creation e
xpression. |
| 8304 * @param typeName the type name to analyzer | 8304 * @param typeName the type name to analyzer |
| 8305 * @return {@code true} if the given type name is used as the type in an insta
nce creation | 8305 * @return {@code true} if the given type name is used as the type in an insta
nce creation |
| 8306 * expression | 8306 * expression |
| 8307 */ | 8307 */ |
| 8308 bool isTypeNameInInstanceCreationExpression(TypeName typeName) { | 8308 bool isTypeNameInInstanceCreationExpression(TypeName typeName) { |
| 8309 ASTNode parent2 = typeName.parent; | 8309 ASTNode parent = typeName.parent; |
| 8310 if (parent2 is ConstructorName && parent2.parent is InstanceCreationExpressi
on) { | 8310 if (parent is ConstructorName && parent.parent is InstanceCreationExpression
) { |
| 8311 ConstructorName constructorName = parent2 as ConstructorName; | 8311 ConstructorName constructorName = parent as ConstructorName; |
| 8312 return constructorName != null && identical(constructorName.type, typeName
); | 8312 return constructorName != null && identical(constructorName.type, typeName
); |
| 8313 } | 8313 } |
| 8314 return false; | 8314 return false; |
| 8315 } | 8315 } |
| 8316 | 8316 |
| 8317 /** | 8317 /** |
| 8318 * Checks if the given type name is used as the type in an is expression. | 8318 * Checks if the given type name is used as the type in an is expression. |
| 8319 * @param typeName the type name to analyzer | 8319 * @param typeName the type name to analyzer |
| 8320 * @return {@code true} if the given type name is used as the type in an is ex
pression | 8320 * @return {@code true} if the given type name is used as the type in an is ex
pression |
| 8321 */ | 8321 */ |
| 8322 bool isTypeNameInIsExpression(TypeName typeName) { | 8322 bool isTypeNameInIsExpression(TypeName typeName) { |
| 8323 ASTNode parent2 = typeName.parent; | 8323 ASTNode parent = typeName.parent; |
| 8324 if (parent2 is IsExpression) { | 8324 if (parent is IsExpression) { |
| 8325 IsExpression isExpression = parent2 as IsExpression; | 8325 IsExpression isExpression = parent as IsExpression; |
| 8326 return identical(isExpression.type, typeName); | 8326 return identical(isExpression.type, typeName); |
| 8327 } | 8327 } |
| 8328 return false; | 8328 return false; |
| 8329 } | 8329 } |
| 8330 | 8330 |
| 8331 /** | 8331 /** |
| 8332 * Checks if the given type name is the target in a redirected constructor. | 8332 * Checks if the given type name is the target in a redirected constructor. |
| 8333 * @param typeName the type name to analyzer | 8333 * @param typeName the type name to analyzer |
| 8334 * @return {@code true} if the given type name is used as the type in a redire
cted constructor | 8334 * @return {@code true} if the given type name is used as the type in a redire
cted constructor |
| 8335 */ | 8335 */ |
| 8336 bool isTypeNameTargetInRedirectedConstructor(TypeName typeName) { | 8336 bool isTypeNameTargetInRedirectedConstructor(TypeName typeName) { |
| 8337 ASTNode parent2 = typeName.parent; | 8337 ASTNode parent = typeName.parent; |
| 8338 if (parent2 is ConstructorName) { | 8338 if (parent is ConstructorName) { |
| 8339 ConstructorName constructorName = parent2 as ConstructorName; | 8339 ConstructorName constructorName = parent as ConstructorName; |
| 8340 parent2 = constructorName.parent; | 8340 parent = constructorName.parent; |
| 8341 if (parent2 is ConstructorDeclaration) { | 8341 if (parent is ConstructorDeclaration) { |
| 8342 ConstructorDeclaration constructorDeclaration = parent2 as ConstructorDe
claration; | 8342 ConstructorDeclaration constructorDeclaration = parent as ConstructorDec
laration; |
| 8343 return constructorName == constructorDeclaration.redirectedConstructor; | 8343 return constructorName == constructorDeclaration.redirectedConstructor; |
| 8344 } | 8344 } |
| 8345 } | 8345 } |
| 8346 return false; | 8346 return false; |
| 8347 } | 8347 } |
| 8348 | 8348 |
| 8349 /** | 8349 /** |
| 8350 * Record that the static type of the given node is the given type. | 8350 * Record that the static type of the given node is the given type. |
| 8351 * @param expression the node whose type is to be recorded | 8351 * @param expression the node whose type is to be recorded |
| 8352 * @param type the static type of the node | 8352 * @param type the static type of the node |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8363 /** | 8363 /** |
| 8364 * Resolve the types in the given with and implements clauses and associate th
ose types with the | 8364 * Resolve the types in the given with and implements clauses and associate th
ose types with the |
| 8365 * given class element. | 8365 * given class element. |
| 8366 * @param classElement the class element with which the mixin and interface ty
pes are to be | 8366 * @param classElement the class element with which the mixin and interface ty
pes are to be |
| 8367 * associated | 8367 * associated |
| 8368 * @param withClause the with clause to be resolved | 8368 * @param withClause the with clause to be resolved |
| 8369 * @param implementsClause the implements clause to be resolved | 8369 * @param implementsClause the implements clause to be resolved |
| 8370 */ | 8370 */ |
| 8371 void resolve(ClassElementImpl classElement, WithClause withClause, ImplementsC
lause implementsClause) { | 8371 void resolve(ClassElementImpl classElement, WithClause withClause, ImplementsC
lause implementsClause) { |
| 8372 if (withClause != null) { | 8372 if (withClause != null) { |
| 8373 List<InterfaceType> mixinTypes2 = resolveTypes(withClause.mixinTypes, Comp
ileTimeErrorCode.MIXIN_OF_NON_CLASS); | 8373 List<InterfaceType> mixinTypes = resolveTypes(withClause.mixinTypes, Compi
leTimeErrorCode.MIXIN_OF_NON_CLASS); |
| 8374 if (classElement != null) { | 8374 if (classElement != null) { |
| 8375 classElement.mixins = mixinTypes2; | 8375 classElement.mixins = mixinTypes; |
| 8376 } | 8376 } |
| 8377 } | 8377 } |
| 8378 if (implementsClause != null) { | 8378 if (implementsClause != null) { |
| 8379 NodeList<TypeName> interfaces2 = implementsClause.interfaces; | 8379 NodeList<TypeName> interfaces = implementsClause.interfaces; |
| 8380 List<InterfaceType> interfaceTypes = resolveTypes(interfaces2, CompileTime
ErrorCode.IMPLEMENTS_NON_CLASS); | 8380 List<InterfaceType> interfaceTypes = resolveTypes(interfaces, CompileTimeE
rrorCode.IMPLEMENTS_NON_CLASS); |
| 8381 List<TypeName> typeNames = new List.from(interfaces2); | 8381 List<TypeName> typeNames = new List.from(interfaces); |
| 8382 String dynamicKeyword = sc.Keyword.DYNAMIC.syntax; | 8382 String dynamicKeyword = sc.Keyword.DYNAMIC.syntax; |
| 8383 List<bool> detectedRepeatOnIndex = new List<bool>.filled(typeNames.length,
false); | 8383 List<bool> detectedRepeatOnIndex = new List<bool>.filled(typeNames.length,
false); |
| 8384 for (int i = 0; i < detectedRepeatOnIndex.length; i++) { | 8384 for (int i = 0; i < detectedRepeatOnIndex.length; i++) { |
| 8385 detectedRepeatOnIndex[i] = false; | 8385 detectedRepeatOnIndex[i] = false; |
| 8386 } | 8386 } |
| 8387 for (int i = 0; i < typeNames.length; i++) { | 8387 for (int i = 0; i < typeNames.length; i++) { |
| 8388 TypeName typeName = typeNames[i]; | 8388 TypeName typeName = typeNames[i]; |
| 8389 String name3 = typeName.name.name; | 8389 String name = typeName.name.name; |
| 8390 if (name3 == dynamicKeyword) { | 8390 if (name == dynamicKeyword) { |
| 8391 reportError(CompileTimeErrorCode.IMPLEMENTS_DYNAMIC, typeName, []); | 8391 reportError(CompileTimeErrorCode.IMPLEMENTS_DYNAMIC, typeName, []); |
| 8392 } | 8392 } |
| 8393 if (!detectedRepeatOnIndex[i]) { | 8393 if (!detectedRepeatOnIndex[i]) { |
| 8394 for (int j = i + 1; j < typeNames.length; j++) { | 8394 for (int j = i + 1; j < typeNames.length; j++) { |
| 8395 Element element3 = typeName.name.element; | 8395 Element element = typeName.name.element; |
| 8396 TypeName typeName2 = typeNames[j]; | 8396 TypeName typeName2 = typeNames[j]; |
| 8397 Identifier identifier2 = typeName2.name; | 8397 Identifier identifier2 = typeName2.name; |
| 8398 String name2 = identifier2.name; | 8398 String name2 = identifier2.name; |
| 8399 Element element2 = identifier2.element; | 8399 Element element2 = identifier2.element; |
| 8400 if (element3 != null && element3 == element2) { | 8400 if (element != null && element == element2) { |
| 8401 detectedRepeatOnIndex[j] = true; | 8401 detectedRepeatOnIndex[j] = true; |
| 8402 reportError(CompileTimeErrorCode.IMPLEMENTS_REPEATED, typeName2, [
name2]); | 8402 reportError(CompileTimeErrorCode.IMPLEMENTS_REPEATED, typeName2, [
name2]); |
| 8403 } | 8403 } |
| 8404 } | 8404 } |
| 8405 } | 8405 } |
| 8406 } | 8406 } |
| 8407 if (classElement != null) { | 8407 if (classElement != null) { |
| 8408 classElement.interfaces = interfaceTypes; | 8408 classElement.interfaces = interfaceTypes; |
| 8409 } | 8409 } |
| 8410 } | 8410 } |
| 8411 } | 8411 } |
| 8412 | 8412 |
| 8413 /** | 8413 /** |
| 8414 * Return the type specified by the given name. | 8414 * Return the type specified by the given name. |
| 8415 * @param typeName the type name specifying the type to be returned | 8415 * @param typeName the type name specifying the type to be returned |
| 8416 * @param nonTypeError the error to produce if the type name is defined to be
something other than | 8416 * @param nonTypeError the error to produce if the type name is defined to be
something other than |
| 8417 * a type | 8417 * a type |
| 8418 * @return the type specified by the type name | 8418 * @return the type specified by the type name |
| 8419 */ | 8419 */ |
| 8420 InterfaceType resolveType(TypeName typeName, ErrorCode nonTypeError) { | 8420 InterfaceType resolveType(TypeName typeName, ErrorCode nonTypeError) { |
| 8421 Type2 type2 = typeName.type; | 8421 Type2 type = typeName.type; |
| 8422 if (type2 is InterfaceType) { | 8422 if (type is InterfaceType) { |
| 8423 return type2 as InterfaceType; | 8423 return type as InterfaceType; |
| 8424 } | 8424 } |
| 8425 Identifier name2 = typeName.name; | 8425 Identifier name = typeName.name; |
| 8426 if (name2.name != sc.Keyword.DYNAMIC.syntax) { | 8426 if (name.name != sc.Keyword.DYNAMIC.syntax) { |
| 8427 reportError(nonTypeError, name2, [name2.name]); | 8427 reportError(nonTypeError, name, [name.name]); |
| 8428 } | 8428 } |
| 8429 return null; | 8429 return null; |
| 8430 } | 8430 } |
| 8431 | 8431 |
| 8432 /** | 8432 /** |
| 8433 * Resolve the types in the given list of type names. | 8433 * Resolve the types in the given list of type names. |
| 8434 * @param typeNames the type names to be resolved | 8434 * @param typeNames the type names to be resolved |
| 8435 * @param nonTypeError the error to produce if the type name is defined to be
something other than | 8435 * @param nonTypeError the error to produce if the type name is defined to be
something other than |
| 8436 * a type | 8436 * a type |
| 8437 * @return an array containing all of the types that were resolved. | 8437 * @return an array containing all of the types that were resolved. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8448 } | 8448 } |
| 8449 void setElement(Identifier typeName, Element element2) { | 8449 void setElement(Identifier typeName, Element element2) { |
| 8450 if (element2 != null) { | 8450 if (element2 != null) { |
| 8451 if (typeName is SimpleIdentifier) { | 8451 if (typeName is SimpleIdentifier) { |
| 8452 ((typeName as SimpleIdentifier)).staticElement = element2; | 8452 ((typeName as SimpleIdentifier)).staticElement = element2; |
| 8453 ((typeName as SimpleIdentifier)).element = element2; | 8453 ((typeName as SimpleIdentifier)).element = element2; |
| 8454 } else if (typeName is PrefixedIdentifier) { | 8454 } else if (typeName is PrefixedIdentifier) { |
| 8455 PrefixedIdentifier identifier = typeName as PrefixedIdentifier; | 8455 PrefixedIdentifier identifier = typeName as PrefixedIdentifier; |
| 8456 identifier.identifier.staticElement = element2; | 8456 identifier.identifier.staticElement = element2; |
| 8457 identifier.identifier.element = element2; | 8457 identifier.identifier.element = element2; |
| 8458 SimpleIdentifier prefix2 = identifier.prefix; | 8458 SimpleIdentifier prefix = identifier.prefix; |
| 8459 Element prefixElement = nameScope.lookup(prefix2, definingLibrary); | 8459 Element prefixElement = nameScope.lookup(prefix, definingLibrary); |
| 8460 if (prefixElement != null) { | 8460 if (prefixElement != null) { |
| 8461 prefix2.staticElement = prefixElement; | 8461 prefix.staticElement = prefixElement; |
| 8462 prefix2.element = prefixElement; | 8462 prefix.element = prefixElement; |
| 8463 } | 8463 } |
| 8464 } | 8464 } |
| 8465 } | 8465 } |
| 8466 } | 8466 } |
| 8467 | 8467 |
| 8468 /** | 8468 /** |
| 8469 * Set the return type and parameter type information for the given function t
ype based on the | 8469 * Set the return type and parameter type information for the given function t
ype based on the |
| 8470 * given return type and parameter elements. | 8470 * given return type and parameter elements. |
| 8471 * @param functionType the function type to be filled in | 8471 * @param functionType the function type to be filled in |
| 8472 * @param returnType the return type of the function, or {@code null} if no ty
pe was declared | 8472 * @param returnType the return type of the function, or {@code null} if no ty
pe was declared |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8604 defineParameters(functionElement); | 8604 defineParameters(functionElement); |
| 8605 } | 8605 } |
| 8606 | 8606 |
| 8607 /** | 8607 /** |
| 8608 * Define the parameters for the given function in the scope that encloses thi
s function. | 8608 * Define the parameters for the given function in the scope that encloses thi
s function. |
| 8609 * @param functionElement the element representing the function represented by
this scope | 8609 * @param functionElement the element representing the function represented by
this scope |
| 8610 */ | 8610 */ |
| 8611 void defineParameters(ExecutableElement functionElement) { | 8611 void defineParameters(ExecutableElement functionElement) { |
| 8612 Scope parameterScope = enclosingScope; | 8612 Scope parameterScope = enclosingScope; |
| 8613 if (functionElement.enclosingElement is ExecutableElement) { | 8613 if (functionElement.enclosingElement is ExecutableElement) { |
| 8614 String name2 = functionElement.name; | 8614 String name = functionElement.name; |
| 8615 if (name2 != null && !name2.isEmpty) { | 8615 if (name != null && !name.isEmpty) { |
| 8616 parameterScope.define(functionElement); | 8616 parameterScope.define(functionElement); |
| 8617 } | 8617 } |
| 8618 } | 8618 } |
| 8619 for (ParameterElement parameter in functionElement.parameters) { | 8619 for (ParameterElement parameter in functionElement.parameters) { |
| 8620 if (!parameter.isInitializingFormal()) { | 8620 if (!parameter.isInitializingFormal()) { |
| 8621 parameterScope.define(parameter); | 8621 parameterScope.define(parameter); |
| 8622 } | 8622 } |
| 8623 } | 8623 } |
| 8624 } | 8624 } |
| 8625 } | 8625 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8748 * Instances of the class {@code LibraryImportScope} represent the scope contain
ing all of the names | 8748 * Instances of the class {@code LibraryImportScope} represent the scope contain
ing all of the names |
| 8749 * available from imported libraries. | 8749 * available from imported libraries. |
| 8750 * @coverage dart.engine.resolver | 8750 * @coverage dart.engine.resolver |
| 8751 */ | 8751 */ |
| 8752 class LibraryImportScope extends Scope { | 8752 class LibraryImportScope extends Scope { |
| 8753 | 8753 |
| 8754 /** | 8754 /** |
| 8755 * @return {@code true} if the given {@link Identifier} is the part of type an
notation. | 8755 * @return {@code true} if the given {@link Identifier} is the part of type an
notation. |
| 8756 */ | 8756 */ |
| 8757 static bool isTypeAnnotation(Identifier identifier) { | 8757 static bool isTypeAnnotation(Identifier identifier) { |
| 8758 ASTNode parent4 = identifier.parent; | 8758 ASTNode parent = identifier.parent; |
| 8759 if (parent4 is TypeName) { | 8759 if (parent is TypeName) { |
| 8760 ASTNode parent2 = parent4.parent; | 8760 ASTNode parent2 = parent.parent; |
| 8761 if (parent2 is FunctionDeclaration) { | 8761 if (parent2 is FunctionDeclaration) { |
| 8762 FunctionDeclaration decl = parent2 as FunctionDeclaration; | 8762 FunctionDeclaration decl = parent2 as FunctionDeclaration; |
| 8763 return identical(decl.returnType, parent4); | 8763 return identical(decl.returnType, parent); |
| 8764 } | 8764 } |
| 8765 if (parent2 is FunctionTypeAlias) { | 8765 if (parent2 is FunctionTypeAlias) { |
| 8766 FunctionTypeAlias decl = parent2 as FunctionTypeAlias; | 8766 FunctionTypeAlias decl = parent2 as FunctionTypeAlias; |
| 8767 return identical(decl.returnType, parent4); | 8767 return identical(decl.returnType, parent); |
| 8768 } | 8768 } |
| 8769 if (parent2 is MethodDeclaration) { | 8769 if (parent2 is MethodDeclaration) { |
| 8770 MethodDeclaration decl = parent2 as MethodDeclaration; | 8770 MethodDeclaration decl = parent2 as MethodDeclaration; |
| 8771 return identical(decl.returnType, parent4); | 8771 return identical(decl.returnType, parent); |
| 8772 } | 8772 } |
| 8773 if (parent2 is VariableDeclarationList) { | 8773 if (parent2 is VariableDeclarationList) { |
| 8774 VariableDeclarationList decl = parent2 as VariableDeclarationList; | 8774 VariableDeclarationList decl = parent2 as VariableDeclarationList; |
| 8775 return identical(decl.type, parent4); | 8775 return identical(decl.type, parent); |
| 8776 } | 8776 } |
| 8777 if (parent2 is SimpleFormalParameter) { | 8777 if (parent2 is SimpleFormalParameter) { |
| 8778 SimpleFormalParameter decl = parent2 as SimpleFormalParameter; | 8778 SimpleFormalParameter decl = parent2 as SimpleFormalParameter; |
| 8779 return identical(decl.type, parent4); | 8779 return identical(decl.type, parent); |
| 8780 } | 8780 } |
| 8781 if (parent2 is TypeParameter) { | 8781 if (parent2 is TypeParameter) { |
| 8782 TypeParameter decl = parent2 as TypeParameter; | 8782 TypeParameter decl = parent2 as TypeParameter; |
| 8783 return identical(decl.bound, parent4); | 8783 return identical(decl.bound, parent); |
| 8784 } | 8784 } |
| 8785 if (parent2 is TypeArgumentList) { | 8785 if (parent2 is TypeArgumentList) { |
| 8786 ASTNode parent3 = parent2.parent; | 8786 ASTNode parent3 = parent2.parent; |
| 8787 if (parent3 is TypeName) { | 8787 if (parent3 is TypeName) { |
| 8788 TypeName typeName = parent3 as TypeName; | 8788 TypeName typeName = parent3 as TypeName; |
| 8789 if (identical((typeName).typeArguments, parent2)) { | 8789 if (identical((typeName).typeArguments, parent2)) { |
| 8790 return isTypeAnnotation(typeName.name); | 8790 return isTypeAnnotation(typeName.name); |
| 8791 } | 8791 } |
| 8792 } | 8792 } |
| 8793 } | 8793 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8992 * @coverage dart.engine.resolver | 8992 * @coverage dart.engine.resolver |
| 8993 */ | 8993 */ |
| 8994 class NamespaceBuilder { | 8994 class NamespaceBuilder { |
| 8995 | 8995 |
| 8996 /** | 8996 /** |
| 8997 * Create a namespace representing the export namespace of the given {@link Ex
portElement}. | 8997 * Create a namespace representing the export namespace of the given {@link Ex
portElement}. |
| 8998 * @param element the export element whose export namespace is to be created | 8998 * @param element the export element whose export namespace is to be created |
| 8999 * @return the export namespace that was created | 8999 * @return the export namespace that was created |
| 9000 */ | 9000 */ |
| 9001 Namespace createExportNamespace(ExportElement element) { | 9001 Namespace createExportNamespace(ExportElement element) { |
| 9002 LibraryElement exportedLibrary2 = element.exportedLibrary; | 9002 LibraryElement exportedLibrary = element.exportedLibrary; |
| 9003 if (exportedLibrary2 == null) { | 9003 if (exportedLibrary == null) { |
| 9004 return Namespace.EMPTY; | 9004 return Namespace.EMPTY; |
| 9005 } | 9005 } |
| 9006 Map<String, Element> definedNames = createExportMapping(exportedLibrary2, ne
w Set<LibraryElement>()); | 9006 Map<String, Element> definedNames = createExportMapping(exportedLibrary, new
Set<LibraryElement>()); |
| 9007 definedNames = apply(definedNames, element.combinators); | 9007 definedNames = apply(definedNames, element.combinators); |
| 9008 return new Namespace(definedNames); | 9008 return new Namespace(definedNames); |
| 9009 } | 9009 } |
| 9010 | 9010 |
| 9011 /** | 9011 /** |
| 9012 * Create a namespace representing the export namespace of the given library. | 9012 * Create a namespace representing the export namespace of the given library. |
| 9013 * @param library the library whose export namespace is to be created | 9013 * @param library the library whose export namespace is to be created |
| 9014 * @return the export namespace that was created | 9014 * @return the export namespace that was created |
| 9015 */ | 9015 */ |
| 9016 Namespace createExportNamespace2(LibraryElement library) => new Namespace(crea
teExportMapping(library, new Set<LibraryElement>())); | 9016 Namespace createExportNamespace2(LibraryElement library) => new Namespace(crea
teExportMapping(library, new Set<LibraryElement>())); |
| 9017 | 9017 |
| 9018 /** | 9018 /** |
| 9019 * Create a namespace representing the import namespace of the given library. | 9019 * Create a namespace representing the import namespace of the given library. |
| 9020 * @param library the library whose import namespace is to be created | 9020 * @param library the library whose import namespace is to be created |
| 9021 * @return the import namespace that was created | 9021 * @return the import namespace that was created |
| 9022 */ | 9022 */ |
| 9023 Namespace createImportNamespace(ImportElement element) { | 9023 Namespace createImportNamespace(ImportElement element) { |
| 9024 LibraryElement importedLibrary2 = element.importedLibrary; | 9024 LibraryElement importedLibrary = element.importedLibrary; |
| 9025 if (importedLibrary2 == null) { | 9025 if (importedLibrary == null) { |
| 9026 return Namespace.EMPTY; | 9026 return Namespace.EMPTY; |
| 9027 } | 9027 } |
| 9028 Map<String, Element> definedNames = createExportMapping(importedLibrary2, ne
w Set<LibraryElement>()); | 9028 Map<String, Element> definedNames = createExportMapping(importedLibrary, new
Set<LibraryElement>()); |
| 9029 definedNames = apply(definedNames, element.combinators); | 9029 definedNames = apply(definedNames, element.combinators); |
| 9030 definedNames = apply2(definedNames, element.prefix); | 9030 definedNames = apply2(definedNames, element.prefix); |
| 9031 return new Namespace(definedNames); | 9031 return new Namespace(definedNames); |
| 9032 } | 9032 } |
| 9033 | 9033 |
| 9034 /** | 9034 /** |
| 9035 * Create a namespace representing the public namespace of the given library. | 9035 * Create a namespace representing the public namespace of the given library. |
| 9036 * @param library the library whose public namespace is to be created | 9036 * @param library the library whose public namespace is to be created |
| 9037 * @return the public namespace that was created | 9037 * @return the public namespace that was created |
| 9038 */ | 9038 */ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 9066 addAll(definedNames2, namespace.definedNames); | 9066 addAll(definedNames2, namespace.definedNames); |
| 9067 } | 9067 } |
| 9068 } | 9068 } |
| 9069 | 9069 |
| 9070 /** | 9070 /** |
| 9071 * Add the given element to the given mapping table if it has a publicly visib
le name. | 9071 * Add the given element to the given mapping table if it has a publicly visib
le name. |
| 9072 * @param definedNames the mapping table to which the public name is to be add
ed | 9072 * @param definedNames the mapping table to which the public name is to be add
ed |
| 9073 * @param element the element to be added | 9073 * @param element the element to be added |
| 9074 */ | 9074 */ |
| 9075 void addIfPublic(Map<String, Element> definedNames, Element element) { | 9075 void addIfPublic(Map<String, Element> definedNames, Element element) { |
| 9076 String name2 = element.name; | 9076 String name = element.name; |
| 9077 if (name2 != null && !Scope.isPrivateName(name2)) { | 9077 if (name != null && !Scope.isPrivateName(name)) { |
| 9078 definedNames[name2] = element; | 9078 definedNames[name] = element; |
| 9079 } | 9079 } |
| 9080 } | 9080 } |
| 9081 | 9081 |
| 9082 /** | 9082 /** |
| 9083 * Add to the given mapping table all of the public top-level names that are d
efined in the given | 9083 * Add to the given mapping table all of the public top-level names that are d
efined in the given |
| 9084 * compilation unit. | 9084 * compilation unit. |
| 9085 * @param definedNames the mapping table to which the public names are to be a
dded | 9085 * @param definedNames the mapping table to which the public names are to be a
dded |
| 9086 * @param compilationUnit the compilation unit defining the top-level names to
be added to this | 9086 * @param compilationUnit the compilation unit defining the top-level names to
be added to this |
| 9087 * namespace | 9087 * namespace |
| 9088 */ | 9088 */ |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9143 * @param visitedElements a set of libraries that do not need to be visited wh
en processing the | 9143 * @param visitedElements a set of libraries that do not need to be visited wh
en processing the |
| 9144 * export directives of the given library because all of the names defined by
them will | 9144 * export directives of the given library because all of the names defined by
them will |
| 9145 * be added by another library | 9145 * be added by another library |
| 9146 * @return the mapping table that was created | 9146 * @return the mapping table that was created |
| 9147 */ | 9147 */ |
| 9148 Map<String, Element> createExportMapping(LibraryElement library, Set<LibraryEl
ement> visitedElements) { | 9148 Map<String, Element> createExportMapping(LibraryElement library, Set<LibraryEl
ement> visitedElements) { |
| 9149 javaSetAdd(visitedElements, library); | 9149 javaSetAdd(visitedElements, library); |
| 9150 try { | 9150 try { |
| 9151 Map<String, Element> definedNames = new Map<String, Element>(); | 9151 Map<String, Element> definedNames = new Map<String, Element>(); |
| 9152 for (ExportElement element in library.exports) { | 9152 for (ExportElement element in library.exports) { |
| 9153 LibraryElement exportedLibrary2 = element.exportedLibrary; | 9153 LibraryElement exportedLibrary = element.exportedLibrary; |
| 9154 if (exportedLibrary2 != null && !visitedElements.contains(exportedLibrar
y2)) { | 9154 if (exportedLibrary != null && !visitedElements.contains(exportedLibrary
)) { |
| 9155 Map<String, Element> exportedNames = createExportMapping(exportedLibra
ry2, visitedElements); | 9155 Map<String, Element> exportedNames = createExportMapping(exportedLibra
ry, visitedElements); |
| 9156 exportedNames = apply(exportedNames, element.combinators); | 9156 exportedNames = apply(exportedNames, element.combinators); |
| 9157 addAll(definedNames, exportedNames); | 9157 addAll(definedNames, exportedNames); |
| 9158 } | 9158 } |
| 9159 } | 9159 } |
| 9160 addAll2(definedNames, ((library.context as InternalAnalysisContext)).getPu
blicNamespace(library)); | 9160 addAll2(definedNames, ((library.context as InternalAnalysisContext)).getPu
blicNamespace(library)); |
| 9161 return definedNames; | 9161 return definedNames; |
| 9162 } finally { | 9162 } finally { |
| 9163 visitedElements.remove(library); | 9163 visitedElements.remove(library); |
| 9164 } | 9164 } |
| 9165 } | 9165 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9287 LibraryElement get definingLibrary; | 9287 LibraryElement get definingLibrary; |
| 9288 | 9288 |
| 9289 /** | 9289 /** |
| 9290 * Return the error code to be used when reporting that a name being defined l
ocally conflicts | 9290 * Return the error code to be used when reporting that a name being defined l
ocally conflicts |
| 9291 * with another element of the same name in the local scope. | 9291 * with another element of the same name in the local scope. |
| 9292 * @param existing the first element to be declared with the conflicting name | 9292 * @param existing the first element to be declared with the conflicting name |
| 9293 * @param duplicate another element declared with the conflicting name | 9293 * @param duplicate another element declared with the conflicting name |
| 9294 * @return the error code used to report duplicate names within a scope | 9294 * @return the error code used to report duplicate names within a scope |
| 9295 */ | 9295 */ |
| 9296 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 9296 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 9297 Source source2 = duplicate.source; | 9297 Source source = duplicate.source; |
| 9298 if (source2 == null) { | 9298 if (source == null) { |
| 9299 source2 = source; | 9299 source = source; |
| 9300 } | 9300 } |
| 9301 return new AnalysisError.con2(source2, duplicate.nameOffset, duplicate.displ
ayName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName]
); | 9301 return new AnalysisError.con2(source, duplicate.nameOffset, duplicate.displa
yName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName])
; |
| 9302 } | 9302 } |
| 9303 | 9303 |
| 9304 /** | 9304 /** |
| 9305 * Return the listener that is to be informed when an error is encountered. | 9305 * Return the listener that is to be informed when an error is encountered. |
| 9306 * @return the listener that is to be informed when an error is encountered | 9306 * @return the listener that is to be informed when an error is encountered |
| 9307 */ | 9307 */ |
| 9308 AnalysisErrorListener get errorListener; | 9308 AnalysisErrorListener get errorListener; |
| 9309 | 9309 |
| 9310 /** | 9310 /** |
| 9311 * Return the source object representing the compilation unit with which error
s related to this | 9311 * Return the source object representing the compilation unit with which error
s related to this |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9420 } | 9420 } |
| 9421 return null; | 9421 return null; |
| 9422 } | 9422 } |
| 9423 Object visitMapLiteral(MapLiteral node) { | 9423 Object visitMapLiteral(MapLiteral node) { |
| 9424 super.visitMapLiteral(node); | 9424 super.visitMapLiteral(node); |
| 9425 bool isConst = node.modifier != null; | 9425 bool isConst = node.modifier != null; |
| 9426 bool reportEqualKeys = true; | 9426 bool reportEqualKeys = true; |
| 9427 Set<Object> keys = new Set<Object>(); | 9427 Set<Object> keys = new Set<Object>(); |
| 9428 List<Expression> invalidKeys = new List<Expression>(); | 9428 List<Expression> invalidKeys = new List<Expression>(); |
| 9429 for (MapLiteralEntry entry in node.entries) { | 9429 for (MapLiteralEntry entry in node.entries) { |
| 9430 Expression key2 = entry.key; | 9430 Expression key = entry.key; |
| 9431 if (isConst) { | 9431 if (isConst) { |
| 9432 EvaluationResultImpl result = validate(key2, CompileTimeErrorCode.NON_CO
NSTANT_MAP_KEY); | 9432 EvaluationResultImpl result = validate(key, CompileTimeErrorCode.NON_CON
STANT_MAP_KEY); |
| 9433 validate(entry.value, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE); | 9433 validate(entry.value, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE); |
| 9434 if (result is ValidResult) { | 9434 if (result is ValidResult) { |
| 9435 Object value2 = ((result as ValidResult)).value; | 9435 Object value = ((result as ValidResult)).value; |
| 9436 if (keys.contains(value2)) { | 9436 if (keys.contains(value)) { |
| 9437 invalidKeys.add(key2); | 9437 invalidKeys.add(key); |
| 9438 } else { | 9438 } else { |
| 9439 javaSetAdd(keys, value2); | 9439 javaSetAdd(keys, value); |
| 9440 } | 9440 } |
| 9441 } | 9441 } |
| 9442 } else { | 9442 } else { |
| 9443 EvaluationResultImpl result = key2.accept(new ConstantVisitor()); | 9443 EvaluationResultImpl result = key.accept(new ConstantVisitor()); |
| 9444 if (result is ValidResult) { | 9444 if (result is ValidResult) { |
| 9445 Object value3 = ((result as ValidResult)).value; | 9445 Object value = ((result as ValidResult)).value; |
| 9446 if (keys.contains(value3)) { | 9446 if (keys.contains(value)) { |
| 9447 invalidKeys.add(key2); | 9447 invalidKeys.add(key); |
| 9448 } else { | 9448 } else { |
| 9449 javaSetAdd(keys, value3); | 9449 javaSetAdd(keys, value); |
| 9450 } | 9450 } |
| 9451 } else { | 9451 } else { |
| 9452 reportEqualKeys = false; | 9452 reportEqualKeys = false; |
| 9453 } | 9453 } |
| 9454 } | 9454 } |
| 9455 } | 9455 } |
| 9456 if (reportEqualKeys) { | 9456 if (reportEqualKeys) { |
| 9457 for (Expression key in invalidKeys) { | 9457 for (Expression key in invalidKeys) { |
| 9458 _errorReporter.reportError2(StaticWarningCode.EQUAL_KEYS_IN_MAP, key, []
); | 9458 _errorReporter.reportError2(StaticWarningCode.EQUAL_KEYS_IN_MAP, key, []
); |
| 9459 } | 9459 } |
| 9460 } | 9460 } |
| 9461 return null; | 9461 return null; |
| 9462 } | 9462 } |
| 9463 Object visitMethodDeclaration(MethodDeclaration node) { | 9463 Object visitMethodDeclaration(MethodDeclaration node) { |
| 9464 super.visitMethodDeclaration(node); | 9464 super.visitMethodDeclaration(node); |
| 9465 validateDefaultValues(node.parameters); | 9465 validateDefaultValues(node.parameters); |
| 9466 return null; | 9466 return null; |
| 9467 } | 9467 } |
| 9468 Object visitSwitchCase(SwitchCase node) { | 9468 Object visitSwitchCase(SwitchCase node) { |
| 9469 super.visitSwitchCase(node); | 9469 super.visitSwitchCase(node); |
| 9470 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION)
; | 9470 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION)
; |
| 9471 return null; | 9471 return null; |
| 9472 } | 9472 } |
| 9473 Object visitVariableDeclaration(VariableDeclaration node) { | 9473 Object visitVariableDeclaration(VariableDeclaration node) { |
| 9474 super.visitVariableDeclaration(node); | 9474 super.visitVariableDeclaration(node); |
| 9475 Expression initializer2 = node.initializer; | 9475 Expression initializer = node.initializer; |
| 9476 if (initializer2 != null && node.isConst()) { | 9476 if (initializer != null && node.isConst()) { |
| 9477 VariableElementImpl element2 = node.element as VariableElementImpl; | 9477 VariableElementImpl element = node.element as VariableElementImpl; |
| 9478 EvaluationResultImpl result = element2.evaluationResult; | 9478 EvaluationResultImpl result = element.evaluationResult; |
| 9479 if (result == null) { | 9479 if (result == null) { |
| 9480 result = validate(initializer2, CompileTimeErrorCode.CONST_INITIALIZED_W
ITH_NON_CONSTANT_VALUE); | 9480 result = validate(initializer, CompileTimeErrorCode.CONST_INITIALIZED_WI
TH_NON_CONSTANT_VALUE); |
| 9481 element2.evaluationResult = result; | 9481 element.evaluationResult = result; |
| 9482 } else if (result is ErrorResult) { | 9482 } else if (result is ErrorResult) { |
| 9483 reportErrors(result, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CON
STANT_VALUE); | 9483 reportErrors(result, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CON
STANT_VALUE); |
| 9484 } | 9484 } |
| 9485 } | 9485 } |
| 9486 return null; | 9486 return null; |
| 9487 } | 9487 } |
| 9488 | 9488 |
| 9489 /** | 9489 /** |
| 9490 * Return {@code true} if the given value is the result of evaluating an expre
ssion whose value is | 9490 * Return {@code true} if the given value is the result of evaluating an expre
ssion whose value is |
| 9491 * a valid key in a const map literal. Keys in const map literals must be eith
er a string, number, | 9491 * a valid key in a const map literal. Keys in const map literals must be eith
er a string, number, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9529 | 9529 |
| 9530 /** | 9530 /** |
| 9531 * Validate that if the passed instance creation is 'const' then all its argum
ents are constant | 9531 * Validate that if the passed instance creation is 'const' then all its argum
ents are constant |
| 9532 * expressions. | 9532 * expressions. |
| 9533 * @param node the instance creation evaluate | 9533 * @param node the instance creation evaluate |
| 9534 */ | 9534 */ |
| 9535 void validateConstantArguments(InstanceCreationExpression node) { | 9535 void validateConstantArguments(InstanceCreationExpression node) { |
| 9536 if (!node.isConst()) { | 9536 if (!node.isConst()) { |
| 9537 return; | 9537 return; |
| 9538 } | 9538 } |
| 9539 ArgumentList argumentList2 = node.argumentList; | 9539 ArgumentList argumentList = node.argumentList; |
| 9540 if (argumentList2 == null) { | 9540 if (argumentList == null) { |
| 9541 return; | 9541 return; |
| 9542 } | 9542 } |
| 9543 for (Expression argument in argumentList2.arguments) { | 9543 for (Expression argument in argumentList.arguments) { |
| 9544 if (argument is NamedExpression) { | 9544 if (argument is NamedExpression) { |
| 9545 argument = ((argument as NamedExpression)).expression; | 9545 argument = ((argument as NamedExpression)).expression; |
| 9546 } | 9546 } |
| 9547 validate(argument, CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT); | 9547 validate(argument, CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT); |
| 9548 } | 9548 } |
| 9549 } | 9549 } |
| 9550 | 9550 |
| 9551 /** | 9551 /** |
| 9552 * Validate that the default value associated with each of the parameters in t
he given list is a | 9552 * Validate that the default value associated with each of the parameters in t
he given list is a |
| 9553 * compile time constant. | 9553 * compile time constant. |
| 9554 * @param parameters the list of parameters to be validated | 9554 * @param parameters the list of parameters to be validated |
| 9555 */ | 9555 */ |
| 9556 void validateDefaultValues(FormalParameterList parameters2) { | 9556 void validateDefaultValues(FormalParameterList parameters2) { |
| 9557 if (parameters2 == null) { | 9557 if (parameters2 == null) { |
| 9558 return; | 9558 return; |
| 9559 } | 9559 } |
| 9560 for (FormalParameter parameter in parameters2.parameters) { | 9560 for (FormalParameter parameter in parameters2.parameters) { |
| 9561 if (parameter is DefaultFormalParameter) { | 9561 if (parameter is DefaultFormalParameter) { |
| 9562 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; | 9562 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; |
| 9563 Expression defaultValue2 = defaultParameter.defaultValue; | 9563 Expression defaultValue = defaultParameter.defaultValue; |
| 9564 if (defaultValue2 != null) { | 9564 if (defaultValue != null) { |
| 9565 EvaluationResultImpl result = validate(defaultValue2, CompileTimeError
Code.NON_CONSTANT_DEFAULT_VALUE); | 9565 EvaluationResultImpl result = validate(defaultValue, CompileTimeErrorC
ode.NON_CONSTANT_DEFAULT_VALUE); |
| 9566 if (defaultParameter.isConst()) { | 9566 if (defaultParameter.isConst()) { |
| 9567 VariableElementImpl element2 = parameter.element as VariableElementI
mpl; | 9567 VariableElementImpl element = parameter.element as VariableElementIm
pl; |
| 9568 element2.evaluationResult = result; | 9568 element.evaluationResult = result; |
| 9569 } | 9569 } |
| 9570 } | 9570 } |
| 9571 } | 9571 } |
| 9572 } | 9572 } |
| 9573 } | 9573 } |
| 9574 | 9574 |
| 9575 /** | 9575 /** |
| 9576 * Validates that the given expression is a compile time constant. | 9576 * Validates that the given expression is a compile time constant. |
| 9577 * @param parameterElements the elements of parameters of constant constructor
, they are | 9577 * @param parameterElements the elements of parameters of constant constructor
, they are |
| 9578 * considered as a valid potentially constant expressions | 9578 * considered as a valid potentially constant expressions |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9598 } | 9598 } |
| 9599 } | 9599 } |
| 9600 | 9600 |
| 9601 /** | 9601 /** |
| 9602 * Validates that the expressions of the given initializers (of a constant con
structor) are all | 9602 * Validates that the expressions of the given initializers (of a constant con
structor) are all |
| 9603 * compile time constants. | 9603 * compile time constants. |
| 9604 * @param constructor the constant constructor declaration to validate | 9604 * @param constructor the constant constructor declaration to validate |
| 9605 */ | 9605 */ |
| 9606 void validateInitializers(ConstructorDeclaration constructor) { | 9606 void validateInitializers(ConstructorDeclaration constructor) { |
| 9607 List<ParameterElement> parameterElements = constructor.parameters.elements; | 9607 List<ParameterElement> parameterElements = constructor.parameters.elements; |
| 9608 NodeList<ConstructorInitializer> initializers2 = constructor.initializers; | 9608 NodeList<ConstructorInitializer> initializers = constructor.initializers; |
| 9609 for (ConstructorInitializer initializer in initializers2) { | 9609 for (ConstructorInitializer initializer in initializers) { |
| 9610 if (initializer is ConstructorFieldInitializer) { | 9610 if (initializer is ConstructorFieldInitializer) { |
| 9611 ConstructorFieldInitializer fieldInitializer = initializer as Constructo
rFieldInitializer; | 9611 ConstructorFieldInitializer fieldInitializer = initializer as Constructo
rFieldInitializer; |
| 9612 validateInitializerExpression(parameterElements, fieldInitializer.expres
sion); | 9612 validateInitializerExpression(parameterElements, fieldInitializer.expres
sion); |
| 9613 } | 9613 } |
| 9614 if (initializer is RedirectingConstructorInvocation) { | 9614 if (initializer is RedirectingConstructorInvocation) { |
| 9615 RedirectingConstructorInvocation invocation = initializer as Redirecting
ConstructorInvocation; | 9615 RedirectingConstructorInvocation invocation = initializer as Redirecting
ConstructorInvocation; |
| 9616 validateInitializerInvocationArguments(parameterElements, invocation.arg
umentList); | 9616 validateInitializerInvocationArguments(parameterElements, invocation.arg
umentList); |
| 9617 } | 9617 } |
| 9618 if (initializer is SuperConstructorInvocation) { | 9618 if (initializer is SuperConstructorInvocation) { |
| 9619 SuperConstructorInvocation invocation = initializer as SuperConstructorI
nvocation; | 9619 SuperConstructorInvocation invocation = initializer as SuperConstructorI
nvocation; |
| 9620 validateInitializerInvocationArguments(parameterElements, invocation.arg
umentList); | 9620 validateInitializerInvocationArguments(parameterElements, invocation.arg
umentList); |
| 9621 } | 9621 } |
| 9622 } | 9622 } |
| 9623 } | 9623 } |
| 9624 } | 9624 } |
| 9625 class ConstantVisitor_10 extends ConstantVisitor { | 9625 class ConstantVisitor_10 extends ConstantVisitor { |
| 9626 final ConstantVerifier ConstantVerifier_this; | 9626 final ConstantVerifier ConstantVerifier_this; |
| 9627 List<ParameterElement> parameterElements; | 9627 List<ParameterElement> parameterElements; |
| 9628 ConstantVisitor_10(this.ConstantVerifier_this, this.parameterElements) : super
(); | 9628 ConstantVisitor_10(this.ConstantVerifier_this, this.parameterElements) : super
(); |
| 9629 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) { | 9629 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) { |
| 9630 Element element2 = node.element; | 9630 Element element = node.element; |
| 9631 for (ParameterElement parameterElement in parameterElements) { | 9631 for (ParameterElement parameterElement in parameterElements) { |
| 9632 if (identical(parameterElement, element2) && parameterElement != null) { | 9632 if (identical(parameterElement, element) && parameterElement != null) { |
| 9633 Type2 type2 = parameterElement.type; | 9633 Type2 type = parameterElement.type; |
| 9634 if (type2 != null) { | 9634 if (type != null) { |
| 9635 if (type2.isDynamic()) { | 9635 if (type.isDynamic()) { |
| 9636 return ValidResult.RESULT_DYNAMIC; | 9636 return ValidResult.RESULT_DYNAMIC; |
| 9637 } | 9637 } |
| 9638 if (type2.isSubtypeOf(ConstantVerifier_this._boolType)) { | 9638 if (type.isSubtypeOf(ConstantVerifier_this._boolType)) { |
| 9639 return ValidResult.RESULT_BOOL; | 9639 return ValidResult.RESULT_BOOL; |
| 9640 } | 9640 } |
| 9641 if (type2.isSubtypeOf(ConstantVerifier_this._intType)) { | 9641 if (type.isSubtypeOf(ConstantVerifier_this._intType)) { |
| 9642 return ValidResult.RESULT_INT; | 9642 return ValidResult.RESULT_INT; |
| 9643 } | 9643 } |
| 9644 if (type2.isSubtypeOf(ConstantVerifier_this._numType)) { | 9644 if (type.isSubtypeOf(ConstantVerifier_this._numType)) { |
| 9645 return ValidResult.RESULT_NUM; | 9645 return ValidResult.RESULT_NUM; |
| 9646 } | 9646 } |
| 9647 if (type2.isSubtypeOf(ConstantVerifier_this._stringType)) { | 9647 if (type.isSubtypeOf(ConstantVerifier_this._stringType)) { |
| 9648 return ValidResult.RESULT_STRING; | 9648 return ValidResult.RESULT_STRING; |
| 9649 } | 9649 } |
| 9650 } | 9650 } |
| 9651 return ValidResult.RESULT_OBJECT; | 9651 return ValidResult.RESULT_OBJECT; |
| 9652 } | 9652 } |
| 9653 } | 9653 } |
| 9654 return super.visitSimpleIdentifier(node); | 9654 return super.visitSimpleIdentifier(node); |
| 9655 } | 9655 } |
| 9656 } | 9656 } |
| 9657 /** | 9657 /** |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9794 } | 9794 } |
| 9795 Object visitArgumentList(ArgumentList node) { | 9795 Object visitArgumentList(ArgumentList node) { |
| 9796 checkForArgumentTypeNotAssignable(node); | 9796 checkForArgumentTypeNotAssignable(node); |
| 9797 return super.visitArgumentList(node); | 9797 return super.visitArgumentList(node); |
| 9798 } | 9798 } |
| 9799 Object visitAssertStatement(AssertStatement node) { | 9799 Object visitAssertStatement(AssertStatement node) { |
| 9800 checkForNonBoolExpression(node); | 9800 checkForNonBoolExpression(node); |
| 9801 return super.visitAssertStatement(node); | 9801 return super.visitAssertStatement(node); |
| 9802 } | 9802 } |
| 9803 Object visitAssignmentExpression(AssignmentExpression node) { | 9803 Object visitAssignmentExpression(AssignmentExpression node) { |
| 9804 sc.Token operator2 = node.operator; | 9804 sc.Token operator = node.operator; |
| 9805 sc.TokenType operatorType = operator2.type; | 9805 sc.TokenType operatorType = operator.type; |
| 9806 if (identical(operatorType, sc.TokenType.EQ)) { | 9806 if (identical(operatorType, sc.TokenType.EQ)) { |
| 9807 checkForInvalidAssignment2(node.leftHandSide, node.rightHandSide); | 9807 checkForInvalidAssignment2(node.leftHandSide, node.rightHandSide); |
| 9808 } else { | 9808 } else { |
| 9809 checkForInvalidAssignment(node); | 9809 checkForInvalidAssignment(node); |
| 9810 } | 9810 } |
| 9811 checkForAssignmentToFinal(node); | 9811 checkForAssignmentToFinal(node); |
| 9812 return super.visitAssignmentExpression(node); | 9812 return super.visitAssignmentExpression(node); |
| 9813 } | 9813 } |
| 9814 Object visitBinaryExpression(BinaryExpression node) { | 9814 Object visitBinaryExpression(BinaryExpression node) { |
| 9815 checkForArgumentTypeNotAssignable2(node.rightOperand); | 9815 checkForArgumentTypeNotAssignable2(node.rightOperand); |
| 9816 return super.visitBinaryExpression(node); | 9816 return super.visitBinaryExpression(node); |
| 9817 } | 9817 } |
| 9818 Object visitCatchClause(CatchClause node) { | 9818 Object visitCatchClause(CatchClause node) { |
| 9819 bool previousIsInCatchClause = _isInCatchClause; | 9819 bool previousIsInCatchClause = _isInCatchClause; |
| 9820 try { | 9820 try { |
| 9821 _isInCatchClause = true; | 9821 _isInCatchClause = true; |
| 9822 return super.visitCatchClause(node); | 9822 return super.visitCatchClause(node); |
| 9823 } finally { | 9823 } finally { |
| 9824 _isInCatchClause = previousIsInCatchClause; | 9824 _isInCatchClause = previousIsInCatchClause; |
| 9825 } | 9825 } |
| 9826 } | 9826 } |
| 9827 Object visitClassDeclaration(ClassDeclaration node) { | 9827 Object visitClassDeclaration(ClassDeclaration node) { |
| 9828 ClassElement outerClass = _enclosingClass; | 9828 ClassElement outerClass = _enclosingClass; |
| 9829 try { | 9829 try { |
| 9830 _enclosingClass = node.element; | 9830 _enclosingClass = node.element; |
| 9831 WithClause withClause2 = node.withClause; | 9831 WithClause withClause = node.withClause; |
| 9832 ImplementsClause implementsClause2 = node.implementsClause; | 9832 ImplementsClause implementsClause = node.implementsClause; |
| 9833 ExtendsClause extendsClause2 = node.extendsClause; | 9833 ExtendsClause extendsClause = node.extendsClause; |
| 9834 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_I
DENTIFIER_AS_TYPE_NAME); | 9834 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_I
DENTIFIER_AS_TYPE_NAME); |
| 9835 checkForMemberWithClassName(); | 9835 checkForMemberWithClassName(); |
| 9836 checkForAllMixinErrorCodes(withClause2); | 9836 checkForAllMixinErrorCodes(withClause); |
| 9837 if (implementsClause2 != null || extendsClause2 != null) { | 9837 if (implementsClause != null || extendsClause != null) { |
| 9838 if (!checkForImplementsDisallowedClass(implementsClause2) && !checkForEx
tendsDisallowedClass(extendsClause2)) { | 9838 if (!checkForImplementsDisallowedClass(implementsClause) && !checkForExt
endsDisallowedClass(extendsClause)) { |
| 9839 checkForNonAbstractClassInheritsAbstractMember(node); | 9839 checkForNonAbstractClassInheritsAbstractMember(node); |
| 9840 checkForInconsistentMethodInheritance(); | 9840 checkForInconsistentMethodInheritance(); |
| 9841 checkForRecursiveInterfaceInheritance(_enclosingClass, new List<ClassE
lement>()); | 9841 checkForRecursiveInterfaceInheritance(_enclosingClass, new List<ClassE
lement>()); |
| 9842 } | 9842 } |
| 9843 } | 9843 } |
| 9844 ClassElement classElement = node.element; | 9844 ClassElement classElement = node.element; |
| 9845 if (classElement != null) { | 9845 if (classElement != null) { |
| 9846 List<FieldElement> fieldElements = classElement.fields; | 9846 List<FieldElement> fieldElements = classElement.fields; |
| 9847 _initialFieldElementsMap = new Map<FieldElement, INIT_STATE>(); | 9847 _initialFieldElementsMap = new Map<FieldElement, INIT_STATE>(); |
| 9848 for (FieldElement fieldElement in fieldElements) { | 9848 for (FieldElement fieldElement in fieldElements) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9937 try { | 9937 try { |
| 9938 SimpleIdentifier identifier = node.name; | 9938 SimpleIdentifier identifier = node.name; |
| 9939 String methoName = ""; | 9939 String methoName = ""; |
| 9940 if (identifier != null) { | 9940 if (identifier != null) { |
| 9941 methoName = identifier.name; | 9941 methoName = identifier.name; |
| 9942 } | 9942 } |
| 9943 _enclosingFunction = node.element; | 9943 _enclosingFunction = node.element; |
| 9944 if (node.isSetter() || node.isGetter()) { | 9944 if (node.isSetter() || node.isGetter()) { |
| 9945 checkForMismatchedAccessorTypes(node, methoName); | 9945 checkForMismatchedAccessorTypes(node, methoName); |
| 9946 if (node.isSetter()) { | 9946 if (node.isSetter()) { |
| 9947 FunctionExpression functionExpression2 = node.functionExpression; | 9947 FunctionExpression functionExpression = node.functionExpression; |
| 9948 if (functionExpression2 != null) { | 9948 if (functionExpression != null) { |
| 9949 checkForWrongNumberOfParametersForSetter(node.name, functionExpressi
on2.parameters); | 9949 checkForWrongNumberOfParametersForSetter(node.name, functionExpressi
on.parameters); |
| 9950 } | 9950 } |
| 9951 TypeName returnType2 = node.returnType; | 9951 TypeName returnType = node.returnType; |
| 9952 checkForNonVoidReturnTypeForSetter(returnType2); | 9952 checkForNonVoidReturnTypeForSetter(returnType); |
| 9953 } | 9953 } |
| 9954 } | 9954 } |
| 9955 return super.visitFunctionDeclaration(node); | 9955 return super.visitFunctionDeclaration(node); |
| 9956 } finally { | 9956 } finally { |
| 9957 _enclosingFunction = outerFunction; | 9957 _enclosingFunction = outerFunction; |
| 9958 } | 9958 } |
| 9959 } | 9959 } |
| 9960 Object visitFunctionExpression(FunctionExpression node) { | 9960 Object visitFunctionExpression(FunctionExpression node) { |
| 9961 ExecutableElement outerFunction = _enclosingFunction; | 9961 ExecutableElement outerFunction = _enclosingFunction; |
| 9962 try { | 9962 try { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9978 Object visitImportDirective(ImportDirective node) { | 9978 Object visitImportDirective(ImportDirective node) { |
| 9979 checkForImportDuplicateLibraryName(node); | 9979 checkForImportDuplicateLibraryName(node); |
| 9980 checkForImportInternalLibrary(node); | 9980 checkForImportInternalLibrary(node); |
| 9981 return super.visitImportDirective(node); | 9981 return super.visitImportDirective(node); |
| 9982 } | 9982 } |
| 9983 Object visitIndexExpression(IndexExpression node) { | 9983 Object visitIndexExpression(IndexExpression node) { |
| 9984 checkForArgumentTypeNotAssignable2(node.index); | 9984 checkForArgumentTypeNotAssignable2(node.index); |
| 9985 return super.visitIndexExpression(node); | 9985 return super.visitIndexExpression(node); |
| 9986 } | 9986 } |
| 9987 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 9987 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 9988 ConstructorName constructorName2 = node.constructorName; | 9988 ConstructorName constructorName = node.constructorName; |
| 9989 TypeName typeName = constructorName2.type; | 9989 TypeName typeName = constructorName.type; |
| 9990 Type2 type2 = typeName.type; | 9990 Type2 type = typeName.type; |
| 9991 if (type2 is InterfaceType) { | 9991 if (type is InterfaceType) { |
| 9992 InterfaceType interfaceType = type2 as InterfaceType; | 9992 InterfaceType interfaceType = type as InterfaceType; |
| 9993 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); | 9993 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); |
| 9994 if (node.isConst()) { | 9994 if (node.isConst()) { |
| 9995 checkForConstWithNonConst(node); | 9995 checkForConstWithNonConst(node); |
| 9996 checkForConstWithUndefinedConstructor(node); | 9996 checkForConstWithUndefinedConstructor(node); |
| 9997 checkForConstWithTypeParameters(node); | 9997 checkForConstWithTypeParameters(node); |
| 9998 } else { | 9998 } else { |
| 9999 checkForNewWithUndefinedConstructor(node); | 9999 checkForNewWithUndefinedConstructor(node); |
| 10000 } | 10000 } |
| 10001 checkForTypeArgumentNotMatchingBounds(node, constructorName2.element, type
Name); | 10001 checkForTypeArgumentNotMatchingBounds(node, constructorName.element, typeN
ame); |
| 10002 } | 10002 } |
| 10003 return super.visitInstanceCreationExpression(node); | 10003 return super.visitInstanceCreationExpression(node); |
| 10004 } | 10004 } |
| 10005 Object visitListLiteral(ListLiteral node) { | 10005 Object visitListLiteral(ListLiteral node) { |
| 10006 if (node.modifier != null) { | 10006 if (node.modifier != null) { |
| 10007 TypeArgumentList typeArguments2 = node.typeArguments; | 10007 TypeArgumentList typeArguments = node.typeArguments; |
| 10008 if (typeArguments2 != null) { | 10008 if (typeArguments != null) { |
| 10009 NodeList<TypeName> arguments2 = typeArguments2.arguments; | 10009 NodeList<TypeName> arguments = typeArguments.arguments; |
| 10010 if (arguments2.length != 0) { | 10010 if (arguments.length != 0) { |
| 10011 checkForInvalidTypeArgumentInConstTypedLiteral(arguments2, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST); | 10011 checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTimeE
rrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST); |
| 10012 } | 10012 } |
| 10013 } | 10013 } |
| 10014 } | 10014 } |
| 10015 return super.visitListLiteral(node); | 10015 return super.visitListLiteral(node); |
| 10016 } | 10016 } |
| 10017 Object visitMapLiteral(MapLiteral node) { | 10017 Object visitMapLiteral(MapLiteral node) { |
| 10018 TypeArgumentList typeArguments2 = node.typeArguments; | 10018 TypeArgumentList typeArguments = node.typeArguments; |
| 10019 if (typeArguments2 != null) { | 10019 if (typeArguments != null) { |
| 10020 NodeList<TypeName> arguments2 = typeArguments2.arguments; | 10020 NodeList<TypeName> arguments = typeArguments.arguments; |
| 10021 if (arguments2.length != 0) { | 10021 if (arguments.length != 0) { |
| 10022 checkForInvalidTypeArgumentForKey(arguments2); | 10022 checkForInvalidTypeArgumentForKey(arguments); |
| 10023 if (node.modifier != null) { | 10023 if (node.modifier != null) { |
| 10024 checkForInvalidTypeArgumentInConstTypedLiteral(arguments2, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP); | 10024 checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTimeE
rrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP); |
| 10025 } | 10025 } |
| 10026 } | 10026 } |
| 10027 } | 10027 } |
| 10028 checkForNonConstMapAsExpressionStatement(node); | 10028 checkForNonConstMapAsExpressionStatement(node); |
| 10029 return super.visitMapLiteral(node); | 10029 return super.visitMapLiteral(node); |
| 10030 } | 10030 } |
| 10031 Object visitMethodDeclaration(MethodDeclaration node) { | 10031 Object visitMethodDeclaration(MethodDeclaration node) { |
| 10032 ExecutableElement previousFunction = _enclosingFunction; | 10032 ExecutableElement previousFunction = _enclosingFunction; |
| 10033 try { | 10033 try { |
| 10034 _enclosingFunction = node.element; | 10034 _enclosingFunction = node.element; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10139 } | 10139 } |
| 10140 Object visitTypeParameter(TypeParameter node) { | 10140 Object visitTypeParameter(TypeParameter node) { |
| 10141 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPE_VARIABLE_NAME); | 10141 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPE_VARIABLE_NAME); |
| 10142 return super.visitTypeParameter(node); | 10142 return super.visitTypeParameter(node); |
| 10143 } | 10143 } |
| 10144 Object visitVariableDeclaration(VariableDeclaration node) { | 10144 Object visitVariableDeclaration(VariableDeclaration node) { |
| 10145 SimpleIdentifier nameNode = node.name; | 10145 SimpleIdentifier nameNode = node.name; |
| 10146 Expression initializerNode = node.initializer; | 10146 Expression initializerNode = node.initializer; |
| 10147 checkForInvalidAssignment2(nameNode, initializerNode); | 10147 checkForInvalidAssignment2(nameNode, initializerNode); |
| 10148 nameNode.accept(this); | 10148 nameNode.accept(this); |
| 10149 String name2 = nameNode.name; | 10149 String name = nameNode.name; |
| 10150 javaSetAdd(_namesForReferenceToDeclaredVariableInInitializer, name2); | 10150 javaSetAdd(_namesForReferenceToDeclaredVariableInInitializer, name); |
| 10151 try { | 10151 try { |
| 10152 if (initializerNode != null) { | 10152 if (initializerNode != null) { |
| 10153 initializerNode.accept(this); | 10153 initializerNode.accept(this); |
| 10154 } | 10154 } |
| 10155 } finally { | 10155 } finally { |
| 10156 _namesForReferenceToDeclaredVariableInInitializer.remove(name2); | 10156 _namesForReferenceToDeclaredVariableInInitializer.remove(name); |
| 10157 } | 10157 } |
| 10158 return null; | 10158 return null; |
| 10159 } | 10159 } |
| 10160 Object visitVariableDeclarationList(VariableDeclarationList node) { | 10160 Object visitVariableDeclarationList(VariableDeclarationList node) { |
| 10161 checkForBuiltInIdentifierAsName2(node); | 10161 checkForBuiltInIdentifierAsName2(node); |
| 10162 return super.visitVariableDeclarationList(node); | 10162 return super.visitVariableDeclarationList(node); |
| 10163 } | 10163 } |
| 10164 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 10164 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 10165 checkForFinalNotInitialized2(node.variables); | 10165 checkForFinalNotInitialized2(node.variables); |
| 10166 return super.visitVariableDeclarationStatement(node); | 10166 return super.visitVariableDeclarationStatement(node); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10202 foundError = true; | 10202 foundError = true; |
| 10203 } | 10203 } |
| 10204 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { | 10204 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { |
| 10205 if (fieldElement.isFinal() || fieldElement.isConst()) { | 10205 if (fieldElement.isFinal() || fieldElement.isConst()) { |
| 10206 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_M
ULTIPLE_TIMES, formalParameter.identifier, [fieldElement.displayName]); | 10206 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_M
ULTIPLE_TIMES, formalParameter.identifier, [fieldElement.displayName]); |
| 10207 foundError = true; | 10207 foundError = true; |
| 10208 } | 10208 } |
| 10209 } | 10209 } |
| 10210 } | 10210 } |
| 10211 } | 10211 } |
| 10212 NodeList<ConstructorInitializer> initializers2 = node.initializers; | 10212 NodeList<ConstructorInitializer> initializers = node.initializers; |
| 10213 for (ConstructorInitializer constructorInitializer in initializers2) { | 10213 for (ConstructorInitializer constructorInitializer in initializers) { |
| 10214 if (constructorInitializer is ConstructorFieldInitializer) { | 10214 if (constructorInitializer is ConstructorFieldInitializer) { |
| 10215 ConstructorFieldInitializer constructorFieldInitializer = constructorIni
tializer as ConstructorFieldInitializer; | 10215 ConstructorFieldInitializer constructorFieldInitializer = constructorIni
tializer as ConstructorFieldInitializer; |
| 10216 SimpleIdentifier fieldName2 = constructorFieldInitializer.fieldName; | 10216 SimpleIdentifier fieldName = constructorFieldInitializer.fieldName; |
| 10217 Element element2 = fieldName2.element; | 10217 Element element = fieldName.element; |
| 10218 if (element2 is FieldElement) { | 10218 if (element is FieldElement) { |
| 10219 FieldElement fieldElement = element2 as FieldElement; | 10219 FieldElement fieldElement = element as FieldElement; |
| 10220 INIT_STATE state = fieldElementsMap[fieldElement]; | 10220 INIT_STATE state = fieldElementsMap[fieldElement]; |
| 10221 if (identical(state, INIT_STATE.NOT_INIT)) { | 10221 if (identical(state, INIT_STATE.NOT_INIT)) { |
| 10222 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_INITIALIZERS; | 10222 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_INITIALIZERS; |
| 10223 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) { | 10223 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) { |
| 10224 if (fieldElement.isFinal() || fieldElement.isConst()) { | 10224 if (fieldElement.isFinal() || fieldElement.isConst()) { |
| 10225 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED
_IN_INITIALIZER_AND_DECLARATION, fieldName2, []); | 10225 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED
_IN_INITIALIZER_AND_DECLARATION, fieldName, []); |
| 10226 foundError = true; | 10226 foundError = true; |
| 10227 } | 10227 } |
| 10228 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { | 10228 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { |
| 10229 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_I
N_PARAMETER_AND_INITIALIZER, fieldName2, []); | 10229 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_I
N_PARAMETER_AND_INITIALIZER, fieldName, []); |
| 10230 foundError = true; | 10230 foundError = true; |
| 10231 } else if (identical(state, INIT_STATE.INIT_IN_INITIALIZERS)) { | 10231 } else if (identical(state, INIT_STATE.INIT_IN_INITIALIZERS)) { |
| 10232 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_B
Y_MULTIPLE_INITIALIZERS, fieldName2, [fieldElement.displayName]); | 10232 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_B
Y_MULTIPLE_INITIALIZERS, fieldName, [fieldElement.displayName]); |
| 10233 foundError = true; | 10233 foundError = true; |
| 10234 } | 10234 } |
| 10235 } | 10235 } |
| 10236 } | 10236 } |
| 10237 } | 10237 } |
| 10238 return foundError; | 10238 return foundError; |
| 10239 } | 10239 } |
| 10240 | 10240 |
| 10241 /** | 10241 /** |
| 10242 * This checks the passed method declaration against override-error codes. | 10242 * This checks the passed method declaration against override-error codes. |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10519 * already exported by other export directive. | 10519 * already exported by other export directive. |
| 10520 * @param node the export directive node to report problem on | 10520 * @param node the export directive node to report problem on |
| 10521 * @return {@code true} if and only if an error code is generated on the passe
d node | 10521 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10522 * @see CompileTimeErrorCode#AMBIGUOUS_EXPORT | 10522 * @see CompileTimeErrorCode#AMBIGUOUS_EXPORT |
| 10523 */ | 10523 */ |
| 10524 bool checkForAmbiguousExport(ExportDirective node) { | 10524 bool checkForAmbiguousExport(ExportDirective node) { |
| 10525 if (node.element is! ExportElement) { | 10525 if (node.element is! ExportElement) { |
| 10526 return false; | 10526 return false; |
| 10527 } | 10527 } |
| 10528 ExportElement exportElement = node.element as ExportElement; | 10528 ExportElement exportElement = node.element as ExportElement; |
| 10529 LibraryElement exportedLibrary2 = exportElement.exportedLibrary; | 10529 LibraryElement exportedLibrary = exportElement.exportedLibrary; |
| 10530 if (exportedLibrary2 == null) { | 10530 if (exportedLibrary == null) { |
| 10531 return false; | 10531 return false; |
| 10532 } | 10532 } |
| 10533 Namespace namespace = new NamespaceBuilder().createExportNamespace(exportEle
ment); | 10533 Namespace namespace = new NamespaceBuilder().createExportNamespace(exportEle
ment); |
| 10534 Set<String> newNames = namespace.definedNames.keys.toSet(); | 10534 Set<String> newNames = namespace.definedNames.keys.toSet(); |
| 10535 for (String name in newNames) { | 10535 for (String name in newNames) { |
| 10536 ExportElement prevElement = _exportedNames[name]; | 10536 ExportElement prevElement = _exportedNames[name]; |
| 10537 if (prevElement != null && prevElement != exportElement) { | 10537 if (prevElement != null && prevElement != exportElement) { |
| 10538 _errorReporter.reportError2(CompileTimeErrorCode.AMBIGUOUS_EXPORT, node,
[name, prevElement.exportedLibrary.definingCompilationUnit.displayName, exporte
dLibrary2.definingCompilationUnit.displayName]); | 10538 _errorReporter.reportError2(CompileTimeErrorCode.AMBIGUOUS_EXPORT, node,
[name, prevElement.exportedLibrary.definingCompilationUnit.displayName, exporte
dLibrary.definingCompilationUnit.displayName]); |
| 10539 return true; | 10539 return true; |
| 10540 } else { | 10540 } else { |
| 10541 _exportedNames[name] = exportElement; | 10541 _exportedNames[name] = exportElement; |
| 10542 } | 10542 } |
| 10543 } | 10543 } |
| 10544 return false; | 10544 return false; |
| 10545 } | 10545 } |
| 10546 | 10546 |
| 10547 /** | 10547 /** |
| 10548 * This verifies that the passed argument definition test identifier is a para
meter. | 10548 * This verifies that the passed argument definition test identifier is a para
meter. |
| 10549 * @param node the {@link ArgumentDefinitionTest} to evaluate | 10549 * @param node the {@link ArgumentDefinitionTest} to evaluate |
| 10550 * @return {@code true} if and only if an error code is generated on the passe
d node | 10550 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10551 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER | 10551 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER |
| 10552 */ | 10552 */ |
| 10553 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) { | 10553 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) { |
| 10554 SimpleIdentifier identifier2 = node.identifier; | 10554 SimpleIdentifier identifier = node.identifier; |
| 10555 Element element2 = identifier2.element; | 10555 Element element = identifier.element; |
| 10556 if (element2 != null && element2 is! ParameterElement) { | 10556 if (element != null && element is! ParameterElement) { |
| 10557 _errorReporter.reportError2(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_
NON_PARAMETER, identifier2, [identifier2.name]); | 10557 _errorReporter.reportError2(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_
NON_PARAMETER, identifier, [identifier.name]); |
| 10558 return true; | 10558 return true; |
| 10559 } | 10559 } |
| 10560 return false; | 10560 return false; |
| 10561 } | 10561 } |
| 10562 | 10562 |
| 10563 /** | 10563 /** |
| 10564 * This verifies that the passed arguments can be assigned to their correspond
ing parameters. | 10564 * This verifies that the passed arguments can be assigned to their correspond
ing parameters. |
| 10565 * @param node the arguments to evaluate | 10565 * @param node the arguments to evaluate |
| 10566 * @return {@code true} if and only if an error code is generated on the passe
d node | 10566 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10567 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 10567 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10580 /** | 10580 /** |
| 10581 * This verifies that the passed argument can be assigned to their correspondi
ng parameters. | 10581 * This verifies that the passed argument can be assigned to their correspondi
ng parameters. |
| 10582 * @param node the argument to evaluate | 10582 * @param node the argument to evaluate |
| 10583 * @return {@code true} if and only if an error code is generated on the passe
d node | 10583 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10584 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 10584 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 10585 */ | 10585 */ |
| 10586 bool checkForArgumentTypeNotAssignable2(Expression argument) { | 10586 bool checkForArgumentTypeNotAssignable2(Expression argument) { |
| 10587 if (argument == null) { | 10587 if (argument == null) { |
| 10588 return false; | 10588 return false; |
| 10589 } | 10589 } |
| 10590 ParameterElement staticParameterElement2 = argument.staticParameterElement; | 10590 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 10591 Type2 staticParameterType = staticParameterElement2 == null ? null : staticP
arameterElement2.type; | 10591 Type2 staticParameterType = staticParameterElement == null ? null : staticPa
rameterElement.type; |
| 10592 Type2 staticArgumentType = getStaticType(argument); | 10592 Type2 staticArgumentType = getStaticType(argument); |
| 10593 if (staticArgumentType == null || staticParameterType == null) { | 10593 if (staticArgumentType == null || staticParameterType == null) { |
| 10594 return false; | 10594 return false; |
| 10595 } | 10595 } |
| 10596 if (_strictMode) { | 10596 if (_strictMode) { |
| 10597 if (staticArgumentType.isAssignableTo(staticParameterType)) { | 10597 if (staticArgumentType.isAssignableTo(staticParameterType)) { |
| 10598 return false; | 10598 return false; |
| 10599 } | 10599 } |
| 10600 _errorReporter.reportError2(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
, argument, [staticArgumentType.displayName, staticParameterType.displayName]); | 10600 _errorReporter.reportError2(StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE
, argument, [staticArgumentType.displayName, staticParameterType.displayName]); |
| 10601 return true; | 10601 return true; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10666 * on the identifier if it is a keyword. | 10666 * on the identifier if it is a keyword. |
| 10667 * @param identifier the identifier to check to ensure that it is not a keywor
d | 10667 * @param identifier the identifier to check to ensure that it is not a keywor
d |
| 10668 * @param errorCode if the passed identifier is a keyword then this error code
is created on the | 10668 * @param errorCode if the passed identifier is a keyword then this error code
is created on the |
| 10669 * identifier, the error code will be one of{@link CompileTimeErrorCode#BUILT_
IN_IDENTIFIER_AS_TYPE_NAME},{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_T
YPE_VARIABLE_NAME} or{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPEDEF_
NAME} | 10669 * identifier, the error code will be one of{@link CompileTimeErrorCode#BUILT_
IN_IDENTIFIER_AS_TYPE_NAME},{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_T
YPE_VARIABLE_NAME} or{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPEDEF_
NAME} |
| 10670 * @return {@code true} if and only if an error code is generated on the passe
d node | 10670 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10671 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE_NAME | 10671 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE_NAME |
| 10672 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME | 10672 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME |
| 10673 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME | 10673 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME |
| 10674 */ | 10674 */ |
| 10675 bool checkForBuiltInIdentifierAsName(SimpleIdentifier identifier, ErrorCode er
rorCode) { | 10675 bool checkForBuiltInIdentifierAsName(SimpleIdentifier identifier, ErrorCode er
rorCode) { |
| 10676 sc.Token token2 = identifier.token; | 10676 sc.Token token = identifier.token; |
| 10677 if (identical(token2.type, sc.TokenType.KEYWORD)) { | 10677 if (identical(token.type, sc.TokenType.KEYWORD)) { |
| 10678 _errorReporter.reportError2(errorCode, identifier, [identifier.name]); | 10678 _errorReporter.reportError2(errorCode, identifier, [identifier.name]); |
| 10679 return true; | 10679 return true; |
| 10680 } | 10680 } |
| 10681 return false; | 10681 return false; |
| 10682 } | 10682 } |
| 10683 | 10683 |
| 10684 /** | 10684 /** |
| 10685 * This verifies that the passed variable declaration list does not have a bui
lt-in identifier. | 10685 * This verifies that the passed variable declaration list does not have a bui
lt-in identifier. |
| 10686 * @param node the variable declaration list to check | 10686 * @param node the variable declaration list to check |
| 10687 * @return {@code true} if and only if an error code is generated on the passe
d node | 10687 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10688 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE | 10688 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE |
| 10689 */ | 10689 */ |
| 10690 bool checkForBuiltInIdentifierAsName2(VariableDeclarationList node) { | 10690 bool checkForBuiltInIdentifierAsName2(VariableDeclarationList node) { |
| 10691 TypeName typeName = node.type; | 10691 TypeName typeName = node.type; |
| 10692 if (typeName != null) { | 10692 if (typeName != null) { |
| 10693 Identifier identifier = typeName.name; | 10693 Identifier identifier = typeName.name; |
| 10694 if (identifier is SimpleIdentifier) { | 10694 if (identifier is SimpleIdentifier) { |
| 10695 SimpleIdentifier simpleIdentifier = identifier as SimpleIdentifier; | 10695 SimpleIdentifier simpleIdentifier = identifier as SimpleIdentifier; |
| 10696 sc.Token token2 = simpleIdentifier.token; | 10696 sc.Token token = simpleIdentifier.token; |
| 10697 if (identical(token2.type, sc.TokenType.KEYWORD)) { | 10697 if (identical(token.type, sc.TokenType.KEYWORD)) { |
| 10698 if (((token2 as sc.KeywordToken)).keyword != sc.Keyword.DYNAMIC) { | 10698 if (((token as sc.KeywordToken)).keyword != sc.Keyword.DYNAMIC) { |
| 10699 _errorReporter.reportError2(CompileTimeErrorCode.BUILT_IN_IDENTIFIER
_AS_TYPE, identifier, [identifier.name]); | 10699 _errorReporter.reportError2(CompileTimeErrorCode.BUILT_IN_IDENTIFIER
_AS_TYPE, identifier, [identifier.name]); |
| 10700 return true; | 10700 return true; |
| 10701 } | 10701 } |
| 10702 } | 10702 } |
| 10703 } | 10703 } |
| 10704 } | 10704 } |
| 10705 return false; | 10705 return false; |
| 10706 } | 10706 } |
| 10707 | 10707 |
| 10708 /** | 10708 /** |
| 10709 * This verifies that the given switch case is terminated with 'break', 'conti
nue', 'return' or | 10709 * This verifies that the given switch case is terminated with 'break', 'conti
nue', 'return' or |
| 10710 * 'throw'. | 10710 * 'throw'. |
| 10711 * @param node the switch case to evaluate | 10711 * @param node the switch case to evaluate |
| 10712 * @return {@code true} if and only if an error code is generated on the passe
d node | 10712 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10713 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED | 10713 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED |
| 10714 */ | 10714 */ |
| 10715 bool checkForCaseBlockNotTerminated(SwitchCase node) { | 10715 bool checkForCaseBlockNotTerminated(SwitchCase node) { |
| 10716 NodeList<Statement> statements2 = node.statements; | 10716 NodeList<Statement> statements = node.statements; |
| 10717 if (statements2.isEmpty) { | 10717 if (statements.isEmpty) { |
| 10718 ASTNode parent2 = node.parent; | 10718 ASTNode parent = node.parent; |
| 10719 if (parent2 is SwitchStatement) { | 10719 if (parent is SwitchStatement) { |
| 10720 SwitchStatement switchStatement = parent2 as SwitchStatement; | 10720 SwitchStatement switchStatement = parent as SwitchStatement; |
| 10721 NodeList<SwitchMember> members2 = switchStatement.members; | 10721 NodeList<SwitchMember> members = switchStatement.members; |
| 10722 int index = members2.indexOf(node); | 10722 int index = members.indexOf(node); |
| 10723 if (index != -1 && index < members2.length - 1) { | 10723 if (index != -1 && index < members.length - 1) { |
| 10724 return false; | 10724 return false; |
| 10725 } | 10725 } |
| 10726 } | 10726 } |
| 10727 } else { | 10727 } else { |
| 10728 Statement statement = statements2[statements2.length - 1]; | 10728 Statement statement = statements[statements.length - 1]; |
| 10729 if (statement is BreakStatement || statement is ContinueStatement || state
ment is ReturnStatement) { | 10729 if (statement is BreakStatement || statement is ContinueStatement || state
ment is ReturnStatement) { |
| 10730 return false; | 10730 return false; |
| 10731 } | 10731 } |
| 10732 if (statement is ExpressionStatement) { | 10732 if (statement is ExpressionStatement) { |
| 10733 Expression expression2 = ((statement as ExpressionStatement)).expression
; | 10733 Expression expression = ((statement as ExpressionStatement)).expression; |
| 10734 if (expression2 is ThrowExpression) { | 10734 if (expression is ThrowExpression) { |
| 10735 return false; | 10735 return false; |
| 10736 } | 10736 } |
| 10737 } | 10737 } |
| 10738 } | 10738 } |
| 10739 _errorReporter.reportError4(StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, nod
e.keyword, []); | 10739 _errorReporter.reportError4(StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, nod
e.keyword, []); |
| 10740 return true; | 10740 return true; |
| 10741 } | 10741 } |
| 10742 | 10742 |
| 10743 /** | 10743 /** |
| 10744 * This verifies that the switch cases in the given switch statement is termin
ated with 'break', | 10744 * This verifies that the switch cases in the given switch statement is termin
ated with 'break', |
| 10745 * 'continue', 'return' or 'throw'. | 10745 * 'continue', 'return' or 'throw'. |
| 10746 * @param node the switch statement containing the cases to be checked | 10746 * @param node the switch statement containing the cases to be checked |
| 10747 * @return {@code true} if and only if an error code is generated on the passe
d node | 10747 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10748 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED | 10748 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED |
| 10749 */ | 10749 */ |
| 10750 bool checkForCaseBlocksNotTerminated(SwitchStatement node) { | 10750 bool checkForCaseBlocksNotTerminated(SwitchStatement node) { |
| 10751 bool foundError = false; | 10751 bool foundError = false; |
| 10752 NodeList<SwitchMember> members2 = node.members; | 10752 NodeList<SwitchMember> members = node.members; |
| 10753 int lastMember = members2.length - 1; | 10753 int lastMember = members.length - 1; |
| 10754 for (int i = 0; i < lastMember; i++) { | 10754 for (int i = 0; i < lastMember; i++) { |
| 10755 SwitchMember member = members2[i]; | 10755 SwitchMember member = members[i]; |
| 10756 if (member is SwitchCase) { | 10756 if (member is SwitchCase) { |
| 10757 foundError = javaBooleanOr(foundError, checkForCaseBlockNotTerminated((m
ember as SwitchCase))); | 10757 foundError = javaBooleanOr(foundError, checkForCaseBlockNotTerminated((m
ember as SwitchCase))); |
| 10758 } | 10758 } |
| 10759 } | 10759 } |
| 10760 return foundError; | 10760 return foundError; |
| 10761 } | 10761 } |
| 10762 | 10762 |
| 10763 /** | 10763 /** |
| 10764 * This verifies that the passed switch statement does not have a case express
ion with the | 10764 * This verifies that the passed switch statement does not have a case express
ion with the |
| 10765 * operator '==' overridden. | 10765 * operator '==' overridden. |
| 10766 * @param node the switch statement to evaluate | 10766 * @param node the switch statement to evaluate |
| 10767 * @return {@code true} if and only if an error code is generated on the passe
d node | 10767 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10768 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS | 10768 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS |
| 10769 */ | 10769 */ |
| 10770 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) { | 10770 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) { |
| 10771 Expression expression2 = node.expression; | 10771 Expression expression = node.expression; |
| 10772 Type2 type = getStaticType(expression2); | 10772 Type2 type = getStaticType(expression); |
| 10773 if (type != null && type != _typeProvider.intType && type != _typeProvider.s
tringType) { | 10773 if (type != null && type != _typeProvider.intType && type != _typeProvider.s
tringType) { |
| 10774 Element element2 = type.element; | 10774 Element element = type.element; |
| 10775 if (element2 is ClassElement) { | 10775 if (element is ClassElement) { |
| 10776 ClassElement classElement = element2 as ClassElement; | 10776 ClassElement classElement = element as ClassElement; |
| 10777 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); | 10777 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); |
| 10778 if (method != null && method.enclosingElement.type != _typeProvider.obje
ctType) { | 10778 if (method != null && method.enclosingElement.type != _typeProvider.obje
ctType) { |
| 10779 _errorReporter.reportError2(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_
IMPLEMENTS_EQUALS, expression2, [element2.displayName]); | 10779 _errorReporter.reportError2(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_
IMPLEMENTS_EQUALS, expression, [element.displayName]); |
| 10780 return true; | 10780 return true; |
| 10781 } | 10781 } |
| 10782 } | 10782 } |
| 10783 } | 10783 } |
| 10784 return false; | 10784 return false; |
| 10785 } | 10785 } |
| 10786 | 10786 |
| 10787 /** | 10787 /** |
| 10788 * This verifies that the passed method declaration is abstract only if the en
closing class is | 10788 * This verifies that the passed method declaration is abstract only if the en
closing class is |
| 10789 * also abstract. | 10789 * also abstract. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10806 * @param node the constructor declaration to evaluate | 10806 * @param node the constructor declaration to evaluate |
| 10807 * @return {@code true} if and only if an error code is generated on the passe
d node | 10807 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10808 * @see CompileTimeErrorCode#DUPLICATE_CONSTRUCTOR_DEFAULT | 10808 * @see CompileTimeErrorCode#DUPLICATE_CONSTRUCTOR_DEFAULT |
| 10809 * @see CompileTimeErrorCode#DUPLICATE_CONSTRUCTOR_NAME | 10809 * @see CompileTimeErrorCode#DUPLICATE_CONSTRUCTOR_NAME |
| 10810 * @see CompileTimeErrorCode#CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD | 10810 * @see CompileTimeErrorCode#CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD |
| 10811 * @see CompileTimeErrorCode#CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD | 10811 * @see CompileTimeErrorCode#CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD |
| 10812 */ | 10812 */ |
| 10813 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node)
{ | 10813 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node)
{ |
| 10814 ConstructorElement constructorElement = node.element; | 10814 ConstructorElement constructorElement = node.element; |
| 10815 SimpleIdentifier constructorName = node.name; | 10815 SimpleIdentifier constructorName = node.name; |
| 10816 String name2 = constructorElement.name; | 10816 String name = constructorElement.name; |
| 10817 ClassElement classElement = constructorElement.enclosingElement; | 10817 ClassElement classElement = constructorElement.enclosingElement; |
| 10818 List<ConstructorElement> constructors2 = classElement.constructors; | 10818 List<ConstructorElement> constructors = classElement.constructors; |
| 10819 for (ConstructorElement otherConstructor in constructors2) { | 10819 for (ConstructorElement otherConstructor in constructors) { |
| 10820 if (identical(otherConstructor, constructorElement)) { | 10820 if (identical(otherConstructor, constructorElement)) { |
| 10821 continue; | 10821 continue; |
| 10822 } | 10822 } |
| 10823 if (name2 == otherConstructor.name) { | 10823 if (name == otherConstructor.name) { |
| 10824 if (name2 == null || name2.length == 0) { | 10824 if (name == null || name.length == 0) { |
| 10825 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR
_DEFAULT, node, []); | 10825 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR
_DEFAULT, node, []); |
| 10826 } else { | 10826 } else { |
| 10827 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR
_NAME, node, [name2]); | 10827 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR
_NAME, node, [name]); |
| 10828 } | 10828 } |
| 10829 return true; | 10829 return true; |
| 10830 } | 10830 } |
| 10831 } | 10831 } |
| 10832 if (constructorName != null && constructorElement != null && !constructorNam
e.isSynthetic()) { | 10832 if (constructorName != null && constructorElement != null && !constructorNam
e.isSynthetic()) { |
| 10833 List<FieldElement> fields2 = classElement.fields; | 10833 List<FieldElement> fields = classElement.fields; |
| 10834 for (FieldElement field in fields2) { | 10834 for (FieldElement field in fields) { |
| 10835 if (field.name == name2) { | 10835 if (field.name == name) { |
| 10836 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT
OR_NAME_AND_FIELD, node, [name2]); | 10836 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT
OR_NAME_AND_FIELD, node, [name]); |
| 10837 return true; | 10837 return true; |
| 10838 } | 10838 } |
| 10839 } | 10839 } |
| 10840 List<MethodElement> methods2 = classElement.methods; | 10840 List<MethodElement> methods = classElement.methods; |
| 10841 for (MethodElement method in methods2) { | 10841 for (MethodElement method in methods) { |
| 10842 if (method.name == name2) { | 10842 if (method.name == name) { |
| 10843 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT
OR_NAME_AND_METHOD, node, [name2]); | 10843 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT
OR_NAME_AND_METHOD, node, [name]); |
| 10844 return true; | 10844 return true; |
| 10845 } | 10845 } |
| 10846 } | 10846 } |
| 10847 } | 10847 } |
| 10848 return false; | 10848 return false; |
| 10849 } | 10849 } |
| 10850 | 10850 |
| 10851 /** | 10851 /** |
| 10852 * This verifies that the superclass of the enclosing class does not declare a
ccessible static | 10852 * This verifies that the superclass of the enclosing class does not declare a
ccessible static |
| 10853 * member with the same name as the passed instance getter/setter method decla
ration. | 10853 * member with the same name as the passed instance getter/setter method decla
ration. |
| 10854 * @param node the method declaration to evaluate | 10854 * @param node the method declaration to evaluate |
| 10855 * @return {@code true} if and only if an error code is generated on the passe
d node | 10855 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10856 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER | 10856 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER |
| 10857 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER | 10857 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER |
| 10858 */ | 10858 */ |
| 10859 bool checkForConflictingInstanceGetterAndSuperclassMember(MethodDeclaration no
de) { | 10859 bool checkForConflictingInstanceGetterAndSuperclassMember(MethodDeclaration no
de) { |
| 10860 if (node.isStatic()) { | 10860 if (node.isStatic()) { |
| 10861 return false; | 10861 return false; |
| 10862 } | 10862 } |
| 10863 SimpleIdentifier nameNode = node.name; | 10863 SimpleIdentifier nameNode = node.name; |
| 10864 if (nameNode == null) { | 10864 if (nameNode == null) { |
| 10865 return false; | 10865 return false; |
| 10866 } | 10866 } |
| 10867 String name2 = nameNode.name; | 10867 String name = nameNode.name; |
| 10868 if (_enclosingClass == null) { | 10868 if (_enclosingClass == null) { |
| 10869 return false; | 10869 return false; |
| 10870 } | 10870 } |
| 10871 InterfaceType enclosingType = _enclosingClass.type; | 10871 InterfaceType enclosingType = _enclosingClass.type; |
| 10872 ExecutableElement superElement; | 10872 ExecutableElement superElement; |
| 10873 superElement = enclosingType.lookUpGetterInSuperclass(name2, _currentLibrary
); | 10873 superElement = enclosingType.lookUpGetterInSuperclass(name, _currentLibrary)
; |
| 10874 if (superElement == null) { | 10874 if (superElement == null) { |
| 10875 superElement = enclosingType.lookUpSetterInSuperclass(name2, _currentLibra
ry); | 10875 superElement = enclosingType.lookUpSetterInSuperclass(name, _currentLibrar
y); |
| 10876 } | 10876 } |
| 10877 if (superElement == null) { | 10877 if (superElement == null) { |
| 10878 superElement = enclosingType.lookUpMethodInSuperclass(name2, _currentLibra
ry); | 10878 superElement = enclosingType.lookUpMethodInSuperclass(name, _currentLibrar
y); |
| 10879 } | 10879 } |
| 10880 if (superElement == null) { | 10880 if (superElement == null) { |
| 10881 return false; | 10881 return false; |
| 10882 } | 10882 } |
| 10883 if (!superElement.isStatic()) { | 10883 if (!superElement.isStatic()) { |
| 10884 return false; | 10884 return false; |
| 10885 } | 10885 } |
| 10886 ClassElement superElementClass = superElement.enclosingElement as ClassEleme
nt; | 10886 ClassElement superElementClass = superElement.enclosingElement as ClassEleme
nt; |
| 10887 InterfaceType superElementType = superElementClass.type; | 10887 InterfaceType superElementType = superElementClass.type; |
| 10888 if (node.isGetter()) { | 10888 if (node.isGetter()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10901 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER | 10901 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER |
| 10902 */ | 10902 */ |
| 10903 bool checkForConflictingStaticGetterAndInstanceSetter(MethodDeclaration node)
{ | 10903 bool checkForConflictingStaticGetterAndInstanceSetter(MethodDeclaration node)
{ |
| 10904 if (!node.isStatic()) { | 10904 if (!node.isStatic()) { |
| 10905 return false; | 10905 return false; |
| 10906 } | 10906 } |
| 10907 SimpleIdentifier nameNode = node.name; | 10907 SimpleIdentifier nameNode = node.name; |
| 10908 if (nameNode == null) { | 10908 if (nameNode == null) { |
| 10909 return false; | 10909 return false; |
| 10910 } | 10910 } |
| 10911 String name2 = nameNode.name; | 10911 String name = nameNode.name; |
| 10912 if (_enclosingClass == null) { | 10912 if (_enclosingClass == null) { |
| 10913 return false; | 10913 return false; |
| 10914 } | 10914 } |
| 10915 InterfaceType enclosingType = _enclosingClass.type; | 10915 InterfaceType enclosingType = _enclosingClass.type; |
| 10916 ExecutableElement setter = enclosingType.lookUpSetter(name2, _currentLibrary
); | 10916 ExecutableElement setter = enclosingType.lookUpSetter(name, _currentLibrary)
; |
| 10917 if (setter == null) { | 10917 if (setter == null) { |
| 10918 return false; | 10918 return false; |
| 10919 } | 10919 } |
| 10920 if (setter.isStatic()) { | 10920 if (setter.isStatic()) { |
| 10921 return false; | 10921 return false; |
| 10922 } | 10922 } |
| 10923 ClassElement setterClass = setter.enclosingElement as ClassElement; | 10923 ClassElement setterClass = setter.enclosingElement as ClassElement; |
| 10924 InterfaceType setterType = setterClass.type; | 10924 InterfaceType setterType = setterClass.type; |
| 10925 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_
INSTANCE_SETTER, nameNode, [setterType.displayName]); | 10925 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_
INSTANCE_SETTER, nameNode, [setterType.displayName]); |
| 10926 return true; | 10926 return true; |
| 10927 } | 10927 } |
| 10928 | 10928 |
| 10929 /** | 10929 /** |
| 10930 * This verifies that the enclosing class does not have an instance member wit
h the same name as | 10930 * This verifies that the enclosing class does not have an instance member wit
h the same name as |
| 10931 * the passed static getter method declaration. | 10931 * the passed static getter method declaration. |
| 10932 * @param node the method declaration to evaluate | 10932 * @param node the method declaration to evaluate |
| 10933 * @return {@code true} if and only if an error code is generated on the passe
d node | 10933 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 10934 * @see StaticWarningCode#CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER | 10934 * @see StaticWarningCode#CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER |
| 10935 */ | 10935 */ |
| 10936 bool checkForConflictingStaticSetterAndInstanceMember(MethodDeclaration node)
{ | 10936 bool checkForConflictingStaticSetterAndInstanceMember(MethodDeclaration node)
{ |
| 10937 if (!node.isStatic()) { | 10937 if (!node.isStatic()) { |
| 10938 return false; | 10938 return false; |
| 10939 } | 10939 } |
| 10940 SimpleIdentifier nameNode = node.name; | 10940 SimpleIdentifier nameNode = node.name; |
| 10941 if (nameNode == null) { | 10941 if (nameNode == null) { |
| 10942 return false; | 10942 return false; |
| 10943 } | 10943 } |
| 10944 String name2 = nameNode.name; | 10944 String name = nameNode.name; |
| 10945 if (_enclosingClass == null) { | 10945 if (_enclosingClass == null) { |
| 10946 return false; | 10946 return false; |
| 10947 } | 10947 } |
| 10948 InterfaceType enclosingType = _enclosingClass.type; | 10948 InterfaceType enclosingType = _enclosingClass.type; |
| 10949 ExecutableElement member; | 10949 ExecutableElement member; |
| 10950 member = enclosingType.lookUpMethod(name2, _currentLibrary); | 10950 member = enclosingType.lookUpMethod(name, _currentLibrary); |
| 10951 if (member == null) { | 10951 if (member == null) { |
| 10952 member = enclosingType.lookUpGetter(name2, _currentLibrary); | 10952 member = enclosingType.lookUpGetter(name, _currentLibrary); |
| 10953 } | 10953 } |
| 10954 if (member == null) { | 10954 if (member == null) { |
| 10955 member = enclosingType.lookUpSetter(name2, _currentLibrary); | 10955 member = enclosingType.lookUpSetter(name, _currentLibrary); |
| 10956 } | 10956 } |
| 10957 if (member == null) { | 10957 if (member == null) { |
| 10958 return false; | 10958 return false; |
| 10959 } | 10959 } |
| 10960 if (member.isStatic()) { | 10960 if (member.isStatic()) { |
| 10961 return false; | 10961 return false; |
| 10962 } | 10962 } |
| 10963 ClassElement memberClass = member.enclosingElement as ClassElement; | 10963 ClassElement memberClass = member.enclosingElement as ClassElement; |
| 10964 InterfaceType memberType = memberClass.type; | 10964 InterfaceType memberType = memberClass.type; |
| 10965 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_
INSTANCE_MEMBER, nameNode, [memberType.displayName]); | 10965 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_
INSTANCE_MEMBER, nameNode, [memberType.displayName]); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11020 * class. | 11020 * class. |
| 11021 * @param node the instance creation expression to evaluate | 11021 * @param node the instance creation expression to evaluate |
| 11022 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th
e{@link InstanceCreationExpression}, this is the AST node that the error is atta
ched to | 11022 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th
e{@link InstanceCreationExpression}, this is the AST node that the error is atta
ched to |
| 11023 * @param type the type being constructed with this {@link InstanceCreationExp
ression} | 11023 * @param type the type being constructed with this {@link InstanceCreationExp
ression} |
| 11024 * @return {@code true} if and only if an error code is generated on the passe
d node | 11024 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11025 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS | 11025 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS |
| 11026 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS | 11026 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS |
| 11027 */ | 11027 */ |
| 11028 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type
Name typeName, InterfaceType type) { | 11028 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type
Name typeName, InterfaceType type) { |
| 11029 if (type.element.isAbstract()) { | 11029 if (type.element.isAbstract()) { |
| 11030 ConstructorElement element2 = node.element; | 11030 ConstructorElement element = node.element; |
| 11031 if (element2 != null && !element2.isFactory()) { | 11031 if (element != null && !element.isFactory()) { |
| 11032 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO
NST)) { | 11032 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO
NST)) { |
| 11033 _errorReporter.reportError2(StaticWarningCode.CONST_WITH_ABSTRACT_CLAS
S, typeName, []); | 11033 _errorReporter.reportError2(StaticWarningCode.CONST_WITH_ABSTRACT_CLAS
S, typeName, []); |
| 11034 } else { | 11034 } else { |
| 11035 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
typeName, []); | 11035 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
typeName, []); |
| 11036 } | 11036 } |
| 11037 return true; | 11037 return true; |
| 11038 } | 11038 } |
| 11039 } | 11039 } |
| 11040 return false; | 11040 return false; |
| 11041 } | 11041 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11061 /** | 11061 /** |
| 11062 * This verifies that the passed 'const' instance creation expression does not
reference any type | 11062 * This verifies that the passed 'const' instance creation expression does not
reference any type |
| 11063 * parameters. | 11063 * parameters. |
| 11064 * <p> | 11064 * <p> |
| 11065 * This method assumes that the instance creation was tested to be 'const' bef
ore being called. | 11065 * This method assumes that the instance creation was tested to be 'const' bef
ore being called. |
| 11066 * @param node the instance creation expression to evaluate | 11066 * @param node the instance creation expression to evaluate |
| 11067 * @return {@code true} if and only if an error code is generated on the passe
d node | 11067 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11068 * @see CompileTimeErrorCode#CONST_WITH_TYPE_PARAMETERS | 11068 * @see CompileTimeErrorCode#CONST_WITH_TYPE_PARAMETERS |
| 11069 */ | 11069 */ |
| 11070 bool checkForConstWithTypeParameters(InstanceCreationExpression node) { | 11070 bool checkForConstWithTypeParameters(InstanceCreationExpression node) { |
| 11071 ConstructorName constructorName2 = node.constructorName; | 11071 ConstructorName constructorName = node.constructorName; |
| 11072 if (constructorName2 == null) { | 11072 if (constructorName == null) { |
| 11073 return false; | 11073 return false; |
| 11074 } | 11074 } |
| 11075 TypeName typeName = constructorName2.type; | 11075 TypeName typeName = constructorName.type; |
| 11076 return checkForConstWithTypeParameters2(typeName); | 11076 return checkForConstWithTypeParameters2(typeName); |
| 11077 } | 11077 } |
| 11078 | 11078 |
| 11079 /** | 11079 /** |
| 11080 * This verifies that the passed type name does not reference any type paramet
ers. | 11080 * This verifies that the passed type name does not reference any type paramet
ers. |
| 11081 * @param typeName the type name to evaluate | 11081 * @param typeName the type name to evaluate |
| 11082 * @return {@code true} if and only if an error code is generated on the passe
d node | 11082 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11083 * @see CompileTimeErrorCode#CONST_WITH_TYPE_PARAMETERS | 11083 * @see CompileTimeErrorCode#CONST_WITH_TYPE_PARAMETERS |
| 11084 */ | 11084 */ |
| 11085 bool checkForConstWithTypeParameters2(TypeName typeName) { | 11085 bool checkForConstWithTypeParameters2(TypeName typeName) { |
| 11086 if (typeName == null) { | 11086 if (typeName == null) { |
| 11087 return false; | 11087 return false; |
| 11088 } | 11088 } |
| 11089 Identifier name2 = typeName.name; | 11089 Identifier name = typeName.name; |
| 11090 if (name2 == null) { | 11090 if (name == null) { |
| 11091 return false; | 11091 return false; |
| 11092 } | 11092 } |
| 11093 if (name2.element is TypeVariableElement) { | 11093 if (name.element is TypeVariableElement) { |
| 11094 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETER
S, name2, []); | 11094 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETER
S, name, []); |
| 11095 } | 11095 } |
| 11096 TypeArgumentList typeArguments2 = typeName.typeArguments; | 11096 TypeArgumentList typeArguments = typeName.typeArguments; |
| 11097 if (typeArguments2 != null) { | 11097 if (typeArguments != null) { |
| 11098 bool hasError = false; | 11098 bool hasError = false; |
| 11099 for (TypeName argument in typeArguments2.arguments) { | 11099 for (TypeName argument in typeArguments.arguments) { |
| 11100 hasError = javaBooleanOr(hasError, checkForConstWithTypeParameters2(argu
ment)); | 11100 hasError = javaBooleanOr(hasError, checkForConstWithTypeParameters2(argu
ment)); |
| 11101 } | 11101 } |
| 11102 return hasError; | 11102 return hasError; |
| 11103 } | 11103 } |
| 11104 return false; | 11104 return false; |
| 11105 } | 11105 } |
| 11106 | 11106 |
| 11107 /** | 11107 /** |
| 11108 * This verifies that if the passed 'const' instance creation expression is be
ing invoked on the | 11108 * This verifies that if the passed 'const' instance creation expression is be
ing invoked on the |
| 11109 * resolved constructor. | 11109 * resolved constructor. |
| 11110 * <p> | 11110 * <p> |
| 11111 * This method assumes that the instance creation was tested to be 'const' bef
ore being called. | 11111 * This method assumes that the instance creation was tested to be 'const' bef
ore being called. |
| 11112 * @param node the instance creation expression to evaluate | 11112 * @param node the instance creation expression to evaluate |
| 11113 * @return {@code true} if and only if an error code is generated on the passe
d node | 11113 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11114 * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR | 11114 * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR |
| 11115 * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT | 11115 * @see CompileTimeErrorCode#CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT |
| 11116 */ | 11116 */ |
| 11117 bool checkForConstWithUndefinedConstructor(InstanceCreationExpression node) { | 11117 bool checkForConstWithUndefinedConstructor(InstanceCreationExpression node) { |
| 11118 if (node.element != null) { | 11118 if (node.element != null) { |
| 11119 return false; | 11119 return false; |
| 11120 } | 11120 } |
| 11121 ConstructorName constructorName2 = node.constructorName; | 11121 ConstructorName constructorName = node.constructorName; |
| 11122 if (constructorName2 == null) { | 11122 if (constructorName == null) { |
| 11123 return false; | 11123 return false; |
| 11124 } | 11124 } |
| 11125 TypeName type2 = constructorName2.type; | 11125 TypeName type = constructorName.type; |
| 11126 if (type2 == null) { | 11126 if (type == null) { |
| 11127 return false; | 11127 return false; |
| 11128 } | 11128 } |
| 11129 Identifier className = type2.name; | 11129 Identifier className = type.name; |
| 11130 SimpleIdentifier name2 = constructorName2.name; | 11130 SimpleIdentifier name = constructorName.name; |
| 11131 if (name2 != null) { | 11131 if (name != null) { |
| 11132 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONS
TRUCTOR, name2, [className, name2]); | 11132 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONS
TRUCTOR, name, [className, name]); |
| 11133 } else { | 11133 } else { |
| 11134 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONS
TRUCTOR_DEFAULT, constructorName2, [className]); | 11134 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONS
TRUCTOR_DEFAULT, constructorName, [className]); |
| 11135 } | 11135 } |
| 11136 return true; | 11136 return true; |
| 11137 } | 11137 } |
| 11138 | 11138 |
| 11139 /** | 11139 /** |
| 11140 * This verifies that there are no default parameters in the passed function t
ype alias. | 11140 * This verifies that there are no default parameters in the passed function t
ype alias. |
| 11141 * @param node the function type alias to evaluate | 11141 * @param node the function type alias to evaluate |
| 11142 * @return {@code true} if and only if an error code is generated on the passe
d node | 11142 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11143 * @see CompileTimeErrorCode#DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS | 11143 * @see CompileTimeErrorCode#DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS |
| 11144 */ | 11144 */ |
| 11145 bool checkForDefaultValueInFunctionTypeAlias(FunctionTypeAlias node) { | 11145 bool checkForDefaultValueInFunctionTypeAlias(FunctionTypeAlias node) { |
| 11146 bool result = false; | 11146 bool result = false; |
| 11147 FormalParameterList formalParameterList = node.parameters; | 11147 FormalParameterList formalParameterList = node.parameters; |
| 11148 NodeList<FormalParameter> parameters2 = formalParameterList.parameters; | 11148 NodeList<FormalParameter> parameters = formalParameterList.parameters; |
| 11149 for (FormalParameter formalParameter in parameters2) { | 11149 for (FormalParameter formalParameter in parameters) { |
| 11150 if (formalParameter is DefaultFormalParameter) { | 11150 if (formalParameter is DefaultFormalParameter) { |
| 11151 DefaultFormalParameter defaultFormalParameter = formalParameter as Defau
ltFormalParameter; | 11151 DefaultFormalParameter defaultFormalParameter = formalParameter as Defau
ltFormalParameter; |
| 11152 if (defaultFormalParameter.defaultValue != null) { | 11152 if (defaultFormalParameter.defaultValue != null) { |
| 11153 _errorReporter.reportError2(CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNC
TION_TYPE_ALIAS, node, []); | 11153 _errorReporter.reportError2(CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNC
TION_TYPE_ALIAS, node, []); |
| 11154 result = true; | 11154 result = true; |
| 11155 } | 11155 } |
| 11156 } | 11156 } |
| 11157 } | 11157 } |
| 11158 return result; | 11158 return result; |
| 11159 } | 11159 } |
| 11160 | 11160 |
| 11161 /** | 11161 /** |
| 11162 * This verifies the passed import has unique name among other exported librar
ies. | 11162 * This verifies the passed import has unique name among other exported librar
ies. |
| 11163 * @param node the export directive to evaluate | 11163 * @param node the export directive to evaluate |
| 11164 * @return {@code true} if and only if an error code is generated on the passe
d node | 11164 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11165 * @see CompileTimeErrorCode#EXPORT_DUPLICATED_LIBRARY_NAME | 11165 * @see CompileTimeErrorCode#EXPORT_DUPLICATED_LIBRARY_NAME |
| 11166 */ | 11166 */ |
| 11167 bool checkForExportDuplicateLibraryName(ExportDirective node) { | 11167 bool checkForExportDuplicateLibraryName(ExportDirective node) { |
| 11168 Element nodeElement = node.element; | 11168 Element nodeElement = node.element; |
| 11169 if (nodeElement is! ExportElement) { | 11169 if (nodeElement is! ExportElement) { |
| 11170 return false; | 11170 return false; |
| 11171 } | 11171 } |
| 11172 ExportElement nodeExportElement = nodeElement as ExportElement; | 11172 ExportElement nodeExportElement = nodeElement as ExportElement; |
| 11173 LibraryElement nodeLibrary = nodeExportElement.exportedLibrary; | 11173 LibraryElement nodeLibrary = nodeExportElement.exportedLibrary; |
| 11174 if (nodeLibrary == null) { | 11174 if (nodeLibrary == null) { |
| 11175 return false; | 11175 return false; |
| 11176 } | 11176 } |
| 11177 String name2 = nodeLibrary.name; | 11177 String name = nodeLibrary.name; |
| 11178 LibraryElement prevLibrary = _nameToExportElement[name2]; | 11178 LibraryElement prevLibrary = _nameToExportElement[name]; |
| 11179 if (prevLibrary != null) { | 11179 if (prevLibrary != null) { |
| 11180 if (prevLibrary != nodeLibrary) { | 11180 if (prevLibrary != nodeLibrary) { |
| 11181 _errorReporter.reportError2(StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_
NAME, node, [prevLibrary.definingCompilationUnit.displayName, nodeLibrary.defini
ngCompilationUnit.displayName, name2]); | 11181 _errorReporter.reportError2(StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_
NAME, node, [prevLibrary.definingCompilationUnit.displayName, nodeLibrary.defini
ngCompilationUnit.displayName, name]); |
| 11182 return true; | 11182 return true; |
| 11183 } | 11183 } |
| 11184 } else { | 11184 } else { |
| 11185 _nameToExportElement[name2] = nodeLibrary; | 11185 _nameToExportElement[name] = nodeLibrary; |
| 11186 } | 11186 } |
| 11187 return false; | 11187 return false; |
| 11188 } | 11188 } |
| 11189 | 11189 |
| 11190 /** | 11190 /** |
| 11191 * Check that if the visiting library is not system, then any passed library s
hould not be SDK | 11191 * Check that if the visiting library is not system, then any passed library s
hould not be SDK |
| 11192 * internal library. | 11192 * internal library. |
| 11193 * @param node the export directive to evaluate | 11193 * @param node the export directive to evaluate |
| 11194 * @return {@code true} if and only if an error code is generated on the passe
d node | 11194 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11195 * @see CompileTimeErrorCode#EXPORT_INTERNAL_LIBRARY | 11195 * @see CompileTimeErrorCode#EXPORT_INTERNAL_LIBRARY |
| 11196 */ | 11196 */ |
| 11197 bool checkForExportInternalLibrary(ExportDirective node) { | 11197 bool checkForExportInternalLibrary(ExportDirective node) { |
| 11198 if (_isInSystemLibrary) { | 11198 if (_isInSystemLibrary) { |
| 11199 return false; | 11199 return false; |
| 11200 } | 11200 } |
| 11201 Element element2 = node.element; | 11201 Element element = node.element; |
| 11202 if (element2 is! ExportElement) { | 11202 if (element is! ExportElement) { |
| 11203 return false; | 11203 return false; |
| 11204 } | 11204 } |
| 11205 ExportElement exportElement = element2 as ExportElement; | 11205 ExportElement exportElement = element as ExportElement; |
| 11206 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; | 11206 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; |
| 11207 String uri2 = exportElement.uri; | 11207 String uri = exportElement.uri; |
| 11208 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri2); | 11208 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri); |
| 11209 if (sdkLibrary == null) { | 11209 if (sdkLibrary == null) { |
| 11210 return false; | 11210 return false; |
| 11211 } | 11211 } |
| 11212 if (!sdkLibrary.isInternal()) { | 11212 if (!sdkLibrary.isInternal()) { |
| 11213 return false; | 11213 return false; |
| 11214 } | 11214 } |
| 11215 _errorReporter.reportError2(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, no
de, [node.uri]); | 11215 _errorReporter.reportError2(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, no
de, [node.uri]); |
| 11216 return true; | 11216 return true; |
| 11217 } | 11217 } |
| 11218 | 11218 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11271 * @see CompileTimeErrorCode#CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE | 11271 * @see CompileTimeErrorCode#CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE |
| 11272 * @see StaticWarningCode#FIELD_INITIALIZER_NOT_ASSIGNABLE | 11272 * @see StaticWarningCode#FIELD_INITIALIZER_NOT_ASSIGNABLE |
| 11273 */ | 11273 */ |
| 11274 bool checkForFieldInitializerNotAssignable(ConstructorFieldInitializer node) { | 11274 bool checkForFieldInitializerNotAssignable(ConstructorFieldInitializer node) { |
| 11275 Element fieldNameElement = node.fieldName.element; | 11275 Element fieldNameElement = node.fieldName.element; |
| 11276 if (fieldNameElement is! FieldElement) { | 11276 if (fieldNameElement is! FieldElement) { |
| 11277 return false; | 11277 return false; |
| 11278 } | 11278 } |
| 11279 FieldElement fieldElement = fieldNameElement as FieldElement; | 11279 FieldElement fieldElement = fieldNameElement as FieldElement; |
| 11280 Type2 fieldType = fieldElement.type; | 11280 Type2 fieldType = fieldElement.type; |
| 11281 Expression expression2 = node.expression; | 11281 Expression expression = node.expression; |
| 11282 if (expression2 == null) { | 11282 if (expression == null) { |
| 11283 return false; | 11283 return false; |
| 11284 } | 11284 } |
| 11285 Type2 staticType = getStaticType(expression2); | 11285 Type2 staticType = getStaticType(expression); |
| 11286 if (staticType == null) { | 11286 if (staticType == null) { |
| 11287 return false; | 11287 return false; |
| 11288 } | 11288 } |
| 11289 if (staticType.isAssignableTo(fieldType)) { | 11289 if (staticType.isAssignableTo(fieldType)) { |
| 11290 return false; | 11290 return false; |
| 11291 } else if (_strictMode) { | 11291 } else if (_strictMode) { |
| 11292 if (_isEnclosingConstructorConst) { | 11292 if (_isEnclosingConstructorConst) { |
| 11293 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FIELD_INITIALIZER
_NOT_ASSIGNABLE, expression2, [staticType.displayName, fieldType.displayName]); | 11293 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FIELD_INITIALIZER
_NOT_ASSIGNABLE, expression, [staticType.displayName, fieldType.displayName]); |
| 11294 } else { | 11294 } else { |
| 11295 _errorReporter.reportError2(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSI
GNABLE, expression2, [staticType.displayName, fieldType.displayName]); | 11295 _errorReporter.reportError2(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSI
GNABLE, expression, [staticType.displayName, fieldType.displayName]); |
| 11296 } | 11296 } |
| 11297 return true; | 11297 return true; |
| 11298 } | 11298 } |
| 11299 Type2 propagatedType = getPropagatedType(expression2); | 11299 Type2 propagatedType = getPropagatedType(expression); |
| 11300 if (propagatedType != null && propagatedType.isAssignableTo(fieldType)) { | 11300 if (propagatedType != null && propagatedType.isAssignableTo(fieldType)) { |
| 11301 return false; | 11301 return false; |
| 11302 } | 11302 } |
| 11303 if (_isEnclosingConstructorConst) { | 11303 if (_isEnclosingConstructorConst) { |
| 11304 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FIELD_INITIALIZER_N
OT_ASSIGNABLE, expression2, [(propagatedType == null ? staticType : propagatedTy
pe).displayName, fieldType.displayName]); | 11304 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FIELD_INITIALIZER_N
OT_ASSIGNABLE, expression, [(propagatedType == null ? staticType : propagatedTyp
e).displayName, fieldType.displayName]); |
| 11305 } else { | 11305 } else { |
| 11306 _errorReporter.reportError2(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGN
ABLE, expression2, [(propagatedType == null ? staticType : propagatedType).displ
ayName, fieldType.displayName]); | 11306 _errorReporter.reportError2(StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGN
ABLE, expression, [(propagatedType == null ? staticType : propagatedType).displa
yName, fieldType.displayName]); |
| 11307 } | 11307 } |
| 11308 return true; | 11308 return true; |
| 11309 } | 11309 } |
| 11310 | 11310 |
| 11311 /** | 11311 /** |
| 11312 * This verifies that the passed field formal parameter is in a constructor de
claration. | 11312 * This verifies that the passed field formal parameter is in a constructor de
claration. |
| 11313 * @param node the field formal parameter to test | 11313 * @param node the field formal parameter to test |
| 11314 * @return {@code true} if and only if an error code is generated on the passe
d node | 11314 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11315 * @see CompileTimeErrorCode#FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR | 11315 * @see CompileTimeErrorCode#FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR |
| 11316 */ | 11316 */ |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11361 /** | 11361 /** |
| 11362 * This verifies that the passed variable declaration list has only initialize
d variables if the | 11362 * This verifies that the passed variable declaration list has only initialize
d variables if the |
| 11363 * list is final or const. This method is called by{@link #checkForFinalNotIni
tialized(ClassDeclaration)},{@link #visitTopLevelVariableDeclaration(TopLevelVar
iableDeclaration)} and{@link #visitVariableDeclarationStatement(VariableDeclarat
ionStatement)}. | 11363 * list is final or const. This method is called by{@link #checkForFinalNotIni
tialized(ClassDeclaration)},{@link #visitTopLevelVariableDeclaration(TopLevelVar
iableDeclaration)} and{@link #visitVariableDeclarationStatement(VariableDeclarat
ionStatement)}. |
| 11364 * @param node the class declaration to test | 11364 * @param node the class declaration to test |
| 11365 * @return {@code true} if and only if an error code is generated on the passe
d node | 11365 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11366 * @see CompileTimeErrorCode#FINAL_NOT_INITIALIZED | 11366 * @see CompileTimeErrorCode#FINAL_NOT_INITIALIZED |
| 11367 */ | 11367 */ |
| 11368 bool checkForFinalNotInitialized2(VariableDeclarationList node) { | 11368 bool checkForFinalNotInitialized2(VariableDeclarationList node) { |
| 11369 bool foundError = false; | 11369 bool foundError = false; |
| 11370 if (!node.isSynthetic() && (node.isConst() || node.isFinal())) { | 11370 if (!node.isSynthetic() && (node.isConst() || node.isFinal())) { |
| 11371 NodeList<VariableDeclaration> variables2 = node.variables; | 11371 NodeList<VariableDeclaration> variables = node.variables; |
| 11372 for (VariableDeclaration variable in variables2) { | 11372 for (VariableDeclaration variable in variables) { |
| 11373 if (variable.initializer == null) { | 11373 if (variable.initializer == null) { |
| 11374 _errorReporter.reportError2(StaticWarningCode.FINAL_NOT_INITIALIZED, v
ariable, [variable.name.name]); | 11374 _errorReporter.reportError2(StaticWarningCode.FINAL_NOT_INITIALIZED, v
ariable, [variable.name.name]); |
| 11375 foundError = true; | 11375 foundError = true; |
| 11376 } | 11376 } |
| 11377 } | 11377 } |
| 11378 } | 11378 } |
| 11379 return foundError; | 11379 return foundError; |
| 11380 } | 11380 } |
| 11381 | 11381 |
| 11382 /** | 11382 /** |
| (...skipping 18 matching lines...) Expand all Loading... |
| 11401 * This verifies that if the passed identifier is part of constructor initiali
zer, then it does | 11401 * This verifies that if the passed identifier is part of constructor initiali
zer, then it does |
| 11402 * not reference implicitly 'this' expression. | 11402 * not reference implicitly 'this' expression. |
| 11403 * @param node the simple identifier to test | 11403 * @param node the simple identifier to test |
| 11404 * @return {@code true} if and only if an error code is generated on the passe
d node | 11404 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11405 * @see CompileTimeErrorCode#IMPLICIT_THIS_REFERENCE_IN_INITIALIZER | 11405 * @see CompileTimeErrorCode#IMPLICIT_THIS_REFERENCE_IN_INITIALIZER |
| 11406 */ | 11406 */ |
| 11407 bool checkForImplicitThisReferenceInInitializer(SimpleIdentifier node) { | 11407 bool checkForImplicitThisReferenceInInitializer(SimpleIdentifier node) { |
| 11408 if (!_isInConstructorInitializer) { | 11408 if (!_isInConstructorInitializer) { |
| 11409 return false; | 11409 return false; |
| 11410 } | 11410 } |
| 11411 Element element2 = node.element; | 11411 Element element = node.element; |
| 11412 if (!(element2 is MethodElement || element2 is PropertyAccessorElement)) { | 11412 if (!(element is MethodElement || element is PropertyAccessorElement)) { |
| 11413 return false; | 11413 return false; |
| 11414 } | 11414 } |
| 11415 ExecutableElement executableElement = element2 as ExecutableElement; | 11415 ExecutableElement executableElement = element as ExecutableElement; |
| 11416 if (executableElement.isStatic()) { | 11416 if (executableElement.isStatic()) { |
| 11417 return false; | 11417 return false; |
| 11418 } | 11418 } |
| 11419 Element enclosingElement2 = element2.enclosingElement; | 11419 Element enclosingElement = element.enclosingElement; |
| 11420 if (enclosingElement2 is! ClassElement) { | 11420 if (enclosingElement is! ClassElement) { |
| 11421 return false; | 11421 return false; |
| 11422 } | 11422 } |
| 11423 ASTNode parent2 = node.parent; | 11423 ASTNode parent = node.parent; |
| 11424 if (parent2 is MethodInvocation) { | 11424 if (parent is MethodInvocation) { |
| 11425 MethodInvocation invocation = parent2 as MethodInvocation; | 11425 MethodInvocation invocation = parent as MethodInvocation; |
| 11426 if (identical(invocation.methodName, node) && invocation.realTarget != nul
l) { | 11426 if (identical(invocation.methodName, node) && invocation.realTarget != nul
l) { |
| 11427 return false; | 11427 return false; |
| 11428 } | 11428 } |
| 11429 } | 11429 } |
| 11430 { | 11430 { |
| 11431 if (parent2 is PropertyAccess) { | 11431 if (parent is PropertyAccess) { |
| 11432 PropertyAccess access = parent2 as PropertyAccess; | 11432 PropertyAccess access = parent as PropertyAccess; |
| 11433 if (identical(access.propertyName, node) && access.realTarget != null) { | 11433 if (identical(access.propertyName, node) && access.realTarget != null) { |
| 11434 return false; | 11434 return false; |
| 11435 } | 11435 } |
| 11436 } | 11436 } |
| 11437 if (parent2 is PrefixedIdentifier) { | 11437 if (parent is PrefixedIdentifier) { |
| 11438 PrefixedIdentifier prefixed = parent2 as PrefixedIdentifier; | 11438 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; |
| 11439 if (identical(prefixed.identifier, node)) { | 11439 if (identical(prefixed.identifier, node)) { |
| 11440 return false; | 11440 return false; |
| 11441 } | 11441 } |
| 11442 } | 11442 } |
| 11443 } | 11443 } |
| 11444 _errorReporter.reportError2(CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_
INITIALIZER, node, []); | 11444 _errorReporter.reportError2(CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_
INITIALIZER, node, []); |
| 11445 return true; | 11445 return true; |
| 11446 } | 11446 } |
| 11447 | 11447 |
| 11448 /** | 11448 /** |
| 11449 * This verifies the passed import has unique name among other imported librar
ies. | 11449 * This verifies the passed import has unique name among other imported librar
ies. |
| 11450 * @param node the import directive to evaluate | 11450 * @param node the import directive to evaluate |
| 11451 * @return {@code true} if and only if an error code is generated on the passe
d node | 11451 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11452 * @see CompileTimeErrorCode#IMPORT_DUPLICATED_LIBRARY_NAME | 11452 * @see CompileTimeErrorCode#IMPORT_DUPLICATED_LIBRARY_NAME |
| 11453 */ | 11453 */ |
| 11454 bool checkForImportDuplicateLibraryName(ImportDirective node) { | 11454 bool checkForImportDuplicateLibraryName(ImportDirective node) { |
| 11455 Element nodeElement = node.element; | 11455 Element nodeElement = node.element; |
| 11456 if (nodeElement is! ImportElement) { | 11456 if (nodeElement is! ImportElement) { |
| 11457 return false; | 11457 return false; |
| 11458 } | 11458 } |
| 11459 ImportElement nodeImportElement = nodeElement as ImportElement; | 11459 ImportElement nodeImportElement = nodeElement as ImportElement; |
| 11460 LibraryElement nodeLibrary = nodeImportElement.importedLibrary; | 11460 LibraryElement nodeLibrary = nodeImportElement.importedLibrary; |
| 11461 if (nodeLibrary == null) { | 11461 if (nodeLibrary == null) { |
| 11462 return false; | 11462 return false; |
| 11463 } | 11463 } |
| 11464 String name2 = nodeLibrary.name; | 11464 String name = nodeLibrary.name; |
| 11465 LibraryElement prevLibrary = _nameToImportElement[name2]; | 11465 LibraryElement prevLibrary = _nameToImportElement[name]; |
| 11466 if (prevLibrary != null) { | 11466 if (prevLibrary != null) { |
| 11467 if (prevLibrary != nodeLibrary) { | 11467 if (prevLibrary != nodeLibrary) { |
| 11468 _errorReporter.reportError2(StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_
NAME, node, [prevLibrary.definingCompilationUnit.displayName, nodeLibrary.defini
ngCompilationUnit.displayName, name2]); | 11468 _errorReporter.reportError2(StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_
NAME, node, [prevLibrary.definingCompilationUnit.displayName, nodeLibrary.defini
ngCompilationUnit.displayName, name]); |
| 11469 return true; | 11469 return true; |
| 11470 } | 11470 } |
| 11471 } else { | 11471 } else { |
| 11472 _nameToImportElement[name2] = nodeLibrary; | 11472 _nameToImportElement[name] = nodeLibrary; |
| 11473 } | 11473 } |
| 11474 return false; | 11474 return false; |
| 11475 } | 11475 } |
| 11476 | 11476 |
| 11477 /** | 11477 /** |
| 11478 * Check that if the visiting library is not system, then any passed library s
hould not be SDK | 11478 * Check that if the visiting library is not system, then any passed library s
hould not be SDK |
| 11479 * internal library. | 11479 * internal library. |
| 11480 * @param node the import directive to evaluate | 11480 * @param node the import directive to evaluate |
| 11481 * @return {@code true} if and only if an error code is generated on the passe
d node | 11481 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11482 * @see CompileTimeErrorCode#IMPORT_INTERNAL_LIBRARY | 11482 * @see CompileTimeErrorCode#IMPORT_INTERNAL_LIBRARY |
| 11483 */ | 11483 */ |
| 11484 bool checkForImportInternalLibrary(ImportDirective node) { | 11484 bool checkForImportInternalLibrary(ImportDirective node) { |
| 11485 if (_isInSystemLibrary) { | 11485 if (_isInSystemLibrary) { |
| 11486 return false; | 11486 return false; |
| 11487 } | 11487 } |
| 11488 Element element2 = node.element; | 11488 Element element = node.element; |
| 11489 if (element2 is! ImportElement) { | 11489 if (element is! ImportElement) { |
| 11490 return false; | 11490 return false; |
| 11491 } | 11491 } |
| 11492 ImportElement importElement = element2 as ImportElement; | 11492 ImportElement importElement = element as ImportElement; |
| 11493 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; | 11493 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; |
| 11494 String uri2 = importElement.uri; | 11494 String uri = importElement.uri; |
| 11495 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri2); | 11495 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri); |
| 11496 if (sdkLibrary == null) { | 11496 if (sdkLibrary == null) { |
| 11497 return false; | 11497 return false; |
| 11498 } | 11498 } |
| 11499 if (!sdkLibrary.isInternal()) { | 11499 if (!sdkLibrary.isInternal()) { |
| 11500 return false; | 11500 return false; |
| 11501 } | 11501 } |
| 11502 _errorReporter.reportError2(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, no
de, [node.uri]); | 11502 _errorReporter.reportError2(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, no
de, [node.uri]); |
| 11503 return true; | 11503 return true; |
| 11504 } | 11504 } |
| 11505 | 11505 |
| 11506 /** | 11506 /** |
| 11507 * This verifies that the passed switch statement case expressions all have th
e same type. | 11507 * This verifies that the passed switch statement case expressions all have th
e same type. |
| 11508 * @param node the switch statement to evaluate | 11508 * @param node the switch statement to evaluate |
| 11509 * @return {@code true} if and only if an error code is generated on the passe
d node | 11509 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11510 * @see CompileTimeErrorCode#INCONSISTENT_CASE_EXPRESSION_TYPES | 11510 * @see CompileTimeErrorCode#INCONSISTENT_CASE_EXPRESSION_TYPES |
| 11511 */ | 11511 */ |
| 11512 bool checkForInconsistentCaseExpressionTypes(SwitchStatement node) { | 11512 bool checkForInconsistentCaseExpressionTypes(SwitchStatement node) { |
| 11513 NodeList<SwitchMember> switchMembers = node.members; | 11513 NodeList<SwitchMember> switchMembers = node.members; |
| 11514 bool foundError = false; | 11514 bool foundError = false; |
| 11515 Type2 firstType = null; | 11515 Type2 firstType = null; |
| 11516 for (SwitchMember switchMember in switchMembers) { | 11516 for (SwitchMember switchMember in switchMembers) { |
| 11517 if (switchMember is SwitchCase) { | 11517 if (switchMember is SwitchCase) { |
| 11518 SwitchCase switchCase = switchMember as SwitchCase; | 11518 SwitchCase switchCase = switchMember as SwitchCase; |
| 11519 Expression expression2 = switchCase.expression; | 11519 Expression expression = switchCase.expression; |
| 11520 if (firstType == null) { | 11520 if (firstType == null) { |
| 11521 firstType = getBestType(expression2); | 11521 firstType = getBestType(expression); |
| 11522 } else { | 11522 } else { |
| 11523 Type2 nType = getBestType(expression2); | 11523 Type2 nType = getBestType(expression); |
| 11524 if (firstType != nType) { | 11524 if (firstType != nType) { |
| 11525 _errorReporter.reportError2(CompileTimeErrorCode.INCONSISTENT_CASE_E
XPRESSION_TYPES, expression2, [expression2.toSource(), firstType.displayName]); | 11525 _errorReporter.reportError2(CompileTimeErrorCode.INCONSISTENT_CASE_E
XPRESSION_TYPES, expression, [expression.toSource(), firstType.displayName]); |
| 11526 foundError = true; | 11526 foundError = true; |
| 11527 } | 11527 } |
| 11528 } | 11528 } |
| 11529 } | 11529 } |
| 11530 } | 11530 } |
| 11531 return foundError; | 11531 return foundError; |
| 11532 } | 11532 } |
| 11533 | 11533 |
| 11534 /** | 11534 /** |
| 11535 * For each class declaration, this method is called which verifies that all i
nherited members are | 11535 * For each class declaration, this method is called which verifies that all i
nherited members are |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11799 * <p> | 11799 * <p> |
| 11800 * This method assumes that the instance creation was tested to be 'new' befor
e being called. | 11800 * This method assumes that the instance creation was tested to be 'new' befor
e being called. |
| 11801 * @param node the instance creation expression to evaluate | 11801 * @param node the instance creation expression to evaluate |
| 11802 * @return {@code true} if and only if an error code is generated on the passe
d node | 11802 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11803 * @see StaticWarningCode#NEW_WITH_UNDEFINED_CONSTRUCTOR | 11803 * @see StaticWarningCode#NEW_WITH_UNDEFINED_CONSTRUCTOR |
| 11804 */ | 11804 */ |
| 11805 bool checkForNewWithUndefinedConstructor(InstanceCreationExpression node) { | 11805 bool checkForNewWithUndefinedConstructor(InstanceCreationExpression node) { |
| 11806 if (node.element != null) { | 11806 if (node.element != null) { |
| 11807 return false; | 11807 return false; |
| 11808 } | 11808 } |
| 11809 ConstructorName constructorName2 = node.constructorName; | 11809 ConstructorName constructorName = node.constructorName; |
| 11810 if (constructorName2 == null) { | 11810 if (constructorName == null) { |
| 11811 return false; | 11811 return false; |
| 11812 } | 11812 } |
| 11813 TypeName type2 = constructorName2.type; | 11813 TypeName type = constructorName.type; |
| 11814 if (type2 == null) { | 11814 if (type == null) { |
| 11815 return false; | 11815 return false; |
| 11816 } | 11816 } |
| 11817 Identifier className = type2.name; | 11817 Identifier className = type.name; |
| 11818 SimpleIdentifier name2 = constructorName2.name; | 11818 SimpleIdentifier name = constructorName.name; |
| 11819 if (name2 != null) { | 11819 if (name != null) { |
| 11820 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCT
OR, name2, [className, name2]); | 11820 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCT
OR, name, [className, name]); |
| 11821 } else { | 11821 } else { |
| 11822 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCT
OR_DEFAULT, constructorName2, [className]); | 11822 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCT
OR_DEFAULT, constructorName, [className]); |
| 11823 } | 11823 } |
| 11824 return true; | 11824 return true; |
| 11825 } | 11825 } |
| 11826 | 11826 |
| 11827 /** | 11827 /** |
| 11828 * This checks that passed class declaration overrides all members required by
its superclasses | 11828 * This checks that passed class declaration overrides all members required by
its superclasses |
| 11829 * and interfaces. | 11829 * and interfaces. |
| 11830 * @param node the {@link ClassDeclaration} to evaluate | 11830 * @param node the {@link ClassDeclaration} to evaluate |
| 11831 * @return {@code true} if and only if an error code is generated on the passe
d node | 11831 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11832 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE | 11832 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE |
| 11833 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO | 11833 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO |
| 11834 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE | 11834 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE |
| 11835 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR | 11835 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR |
| 11836 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLU
S | 11836 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLU
S |
| 11837 */ | 11837 */ |
| 11838 bool checkForNonAbstractClassInheritsAbstractMember(ClassDeclaration node) { | 11838 bool checkForNonAbstractClassInheritsAbstractMember(ClassDeclaration node) { |
| 11839 if (_enclosingClass.isAbstract()) { | 11839 if (_enclosingClass.isAbstract()) { |
| 11840 return false; | 11840 return false; |
| 11841 } | 11841 } |
| 11842 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>(); | 11842 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>(); |
| 11843 Set<String> methodsInEnclosingClass = new Set<String>(); | 11843 Set<String> methodsInEnclosingClass = new Set<String>(); |
| 11844 Set<String> accessorsInEnclosingClass = new Set<String>(); | 11844 Set<String> accessorsInEnclosingClass = new Set<String>(); |
| 11845 List<MethodElement> methods2 = _enclosingClass.methods; | 11845 List<MethodElement> methods = _enclosingClass.methods; |
| 11846 for (MethodElement method in methods2) { | 11846 for (MethodElement method in methods) { |
| 11847 javaSetAdd(methodsInEnclosingClass, method.name); | 11847 javaSetAdd(methodsInEnclosingClass, method.name); |
| 11848 } | 11848 } |
| 11849 List<PropertyAccessorElement> accessors2 = _enclosingClass.accessors; | 11849 List<PropertyAccessorElement> accessors = _enclosingClass.accessors; |
| 11850 for (PropertyAccessorElement accessor in accessors2) { | 11850 for (PropertyAccessorElement accessor in accessors) { |
| 11851 javaSetAdd(accessorsInEnclosingClass, accessor.name); | 11851 javaSetAdd(accessorsInEnclosingClass, accessor.name); |
| 11852 } | 11852 } |
| 11853 Map<String, ExecutableElement> membersInheritedFromSuperclasses = _inheritan
ceManager.getMapOfMembersInheritedFromClasses(_enclosingClass); | 11853 Map<String, ExecutableElement> membersInheritedFromSuperclasses = _inheritan
ceManager.getMapOfMembersInheritedFromClasses(_enclosingClass); |
| 11854 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe
ritedFromSuperclasses)) { | 11854 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe
ritedFromSuperclasses)) { |
| 11855 ExecutableElement executableElt = entry.getValue(); | 11855 ExecutableElement executableElt = entry.getValue(); |
| 11856 if (executableElt is MethodElement) { | 11856 if (executableElt is MethodElement) { |
| 11857 MethodElement methodElt = executableElt as MethodElement; | 11857 MethodElement methodElt = executableElt as MethodElement; |
| 11858 if (methodElt.isAbstract()) { | 11858 if (methodElt.isAbstract()) { |
| 11859 String methodName = entry.getKey(); | 11859 String methodName = entry.getKey(); |
| 11860 if (!methodsInEnclosingClass.contains(methodName)) { | 11860 if (!methodsInEnclosingClass.contains(methodName)) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11992 } | 11992 } |
| 11993 | 11993 |
| 11994 /** | 11994 /** |
| 11995 * This verifies the passed method declaration of operator {@code \[\]=}, has
{@code void} return | 11995 * This verifies the passed method declaration of operator {@code \[\]=}, has
{@code void} return |
| 11996 * type. | 11996 * type. |
| 11997 * @param node the method declaration to evaluate | 11997 * @param node the method declaration to evaluate |
| 11998 * @return {@code true} if and only if an error code is generated on the passe
d node | 11998 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 11999 * @see StaticWarningCode#NON_VOID_RETURN_FOR_OPERATOR | 11999 * @see StaticWarningCode#NON_VOID_RETURN_FOR_OPERATOR |
| 12000 */ | 12000 */ |
| 12001 bool checkForNonVoidReturnTypeForOperator(MethodDeclaration node) { | 12001 bool checkForNonVoidReturnTypeForOperator(MethodDeclaration node) { |
| 12002 SimpleIdentifier name2 = node.name; | 12002 SimpleIdentifier name = node.name; |
| 12003 if (name2.name != "[]=") { | 12003 if (name.name != "[]=") { |
| 12004 return false; | 12004 return false; |
| 12005 } | 12005 } |
| 12006 TypeName typeName = node.returnType; | 12006 TypeName typeName = node.returnType; |
| 12007 if (typeName != null) { | 12007 if (typeName != null) { |
| 12008 Type2 type2 = typeName.type; | 12008 Type2 type = typeName.type; |
| 12009 if (type2 != null && !type2.isVoid()) { | 12009 if (type != null && !type.isVoid()) { |
| 12010 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_OPERAT
OR, typeName, []); | 12010 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_OPERAT
OR, typeName, []); |
| 12011 } | 12011 } |
| 12012 } | 12012 } |
| 12013 return false; | 12013 return false; |
| 12014 } | 12014 } |
| 12015 | 12015 |
| 12016 /** | 12016 /** |
| 12017 * This verifies the passed setter has no return type or the {@code void} retu
rn type. | 12017 * This verifies the passed setter has no return type or the {@code void} retu
rn type. |
| 12018 * @param typeName the type name to evaluate | 12018 * @param typeName the type name to evaluate |
| 12019 * @return {@code true} if and only if an error code is generated on the passe
d node | 12019 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12020 * @see StaticWarningCode#NON_VOID_RETURN_FOR_SETTER | 12020 * @see StaticWarningCode#NON_VOID_RETURN_FOR_SETTER |
| 12021 */ | 12021 */ |
| 12022 bool checkForNonVoidReturnTypeForSetter(TypeName typeName) { | 12022 bool checkForNonVoidReturnTypeForSetter(TypeName typeName) { |
| 12023 if (typeName != null) { | 12023 if (typeName != null) { |
| 12024 Type2 type2 = typeName.type; | 12024 Type2 type = typeName.type; |
| 12025 if (type2 != null && !type2.isVoid()) { | 12025 if (type != null && !type.isVoid()) { |
| 12026 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_SETTER
, typeName, []); | 12026 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_SETTER
, typeName, []); |
| 12027 } | 12027 } |
| 12028 } | 12028 } |
| 12029 return false; | 12029 return false; |
| 12030 } | 12030 } |
| 12031 | 12031 |
| 12032 /** | 12032 /** |
| 12033 * This verifies the passed operator-method declaration, does not have an opti
onal parameter. | 12033 * This verifies the passed operator-method declaration, does not have an opti
onal parameter. |
| 12034 * <p> | 12034 * <p> |
| 12035 * This method assumes that the method declaration was tested to be an operato
r declaration before | 12035 * This method assumes that the method declaration was tested to be an operato
r declaration before |
| (...skipping 18 matching lines...) Expand all Loading... |
| 12054 return foundError; | 12054 return foundError; |
| 12055 } | 12055 } |
| 12056 | 12056 |
| 12057 /** | 12057 /** |
| 12058 * This checks for named optional parameters that begin with '_'. | 12058 * This checks for named optional parameters that begin with '_'. |
| 12059 * @param node the default formal parameter to evaluate | 12059 * @param node the default formal parameter to evaluate |
| 12060 * @return {@code true} if and only if an error code is generated on the passe
d node | 12060 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12061 * @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER | 12061 * @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER |
| 12062 */ | 12062 */ |
| 12063 bool checkForPrivateOptionalParameter(DefaultFormalParameter node) { | 12063 bool checkForPrivateOptionalParameter(DefaultFormalParameter node) { |
| 12064 sc.Token separator2 = node.separator; | 12064 sc.Token separator = node.separator; |
| 12065 if (separator2 != null && separator2.lexeme == ":") { | 12065 if (separator != null && separator.lexeme == ":") { |
| 12066 NormalFormalParameter parameter2 = node.parameter; | 12066 NormalFormalParameter parameter = node.parameter; |
| 12067 SimpleIdentifier name = parameter2.identifier; | 12067 SimpleIdentifier name = parameter.identifier; |
| 12068 if (!name.isSynthetic() && name.name.startsWith("_")) { | 12068 if (!name.isSynthetic() && name.name.startsWith("_")) { |
| 12069 _errorReporter.reportError2(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAME
TER, node, []); | 12069 _errorReporter.reportError2(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAME
TER, node, []); |
| 12070 return true; | 12070 return true; |
| 12071 } | 12071 } |
| 12072 } | 12072 } |
| 12073 return false; | 12073 return false; |
| 12074 } | 12074 } |
| 12075 | 12075 |
| 12076 /** | 12076 /** |
| 12077 * This checks if the passed constructor declaration is the redirecting genera
tive constructor and | 12077 * This checks if the passed constructor declaration is the redirecting genera
tive constructor and |
| 12078 * references itself directly or indirectly. | 12078 * references itself directly or indirectly. |
| 12079 * @param node the constructor declaration to evaluate | 12079 * @param node the constructor declaration to evaluate |
| 12080 * @return {@code true} if and only if an error code is generated on the passe
d node | 12080 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12081 * @see CompileTimeErrorCode#RECURSIVE_CONSTRUCTOR_REDIRECT | 12081 * @see CompileTimeErrorCode#RECURSIVE_CONSTRUCTOR_REDIRECT |
| 12082 */ | 12082 */ |
| 12083 bool checkForRecursiveConstructorRedirect(ConstructorDeclaration node) { | 12083 bool checkForRecursiveConstructorRedirect(ConstructorDeclaration node) { |
| 12084 if (node.factoryKeyword != null) { | 12084 if (node.factoryKeyword != null) { |
| 12085 return false; | 12085 return false; |
| 12086 } | 12086 } |
| 12087 for (ConstructorInitializer initializer in node.initializers) { | 12087 for (ConstructorInitializer initializer in node.initializers) { |
| 12088 if (initializer is RedirectingConstructorInvocation) { | 12088 if (initializer is RedirectingConstructorInvocation) { |
| 12089 ConstructorElement element2 = node.element; | 12089 ConstructorElement element = node.element; |
| 12090 if (!hasRedirectingFactoryConstructorCycle(element2)) { | 12090 if (!hasRedirectingFactoryConstructorCycle(element)) { |
| 12091 return false; | 12091 return false; |
| 12092 } | 12092 } |
| 12093 _errorReporter.reportError2(CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_R
EDIRECT, initializer, []); | 12093 _errorReporter.reportError2(CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_R
EDIRECT, initializer, []); |
| 12094 return true; | 12094 return true; |
| 12095 } | 12095 } |
| 12096 } | 12096 } |
| 12097 return false; | 12097 return false; |
| 12098 } | 12098 } |
| 12099 | 12099 |
| 12100 /** | 12100 /** |
| 12101 * This checks if the passed constructor declaration has redirected constructo
r and references | 12101 * This checks if the passed constructor declaration has redirected constructo
r and references |
| 12102 * itself directly or indirectly. | 12102 * itself directly or indirectly. |
| 12103 * @param node the constructor declaration to evaluate | 12103 * @param node the constructor declaration to evaluate |
| 12104 * @return {@code true} if and only if an error code is generated on the passe
d node | 12104 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12105 * @see CompileTimeErrorCode#RECURSIVE_FACTORY_REDIRECT | 12105 * @see CompileTimeErrorCode#RECURSIVE_FACTORY_REDIRECT |
| 12106 */ | 12106 */ |
| 12107 bool checkForRecursiveFactoryRedirect(ConstructorDeclaration node) { | 12107 bool checkForRecursiveFactoryRedirect(ConstructorDeclaration node) { |
| 12108 ConstructorName redirectedConstructorNode = node.redirectedConstructor; | 12108 ConstructorName redirectedConstructorNode = node.redirectedConstructor; |
| 12109 if (redirectedConstructorNode == null) { | 12109 if (redirectedConstructorNode == null) { |
| 12110 return false; | 12110 return false; |
| 12111 } | 12111 } |
| 12112 ConstructorElement element2 = node.element; | 12112 ConstructorElement element = node.element; |
| 12113 if (!hasRedirectingFactoryConstructorCycle(element2)) { | 12113 if (!hasRedirectingFactoryConstructorCycle(element)) { |
| 12114 return false; | 12114 return false; |
| 12115 } | 12115 } |
| 12116 _errorReporter.reportError2(CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
redirectedConstructorNode, []); | 12116 _errorReporter.reportError2(CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
redirectedConstructorNode, []); |
| 12117 return true; | 12117 return true; |
| 12118 } | 12118 } |
| 12119 | 12119 |
| 12120 /** | 12120 /** |
| 12121 * This checks the class declaration is not a superinterface to itself. | 12121 * This checks the class declaration is not a superinterface to itself. |
| 12122 * @param classElt the class element to test | 12122 * @param classElt the class element to test |
| 12123 * @param list a list containing the potentially cyclic implements path | 12123 * @param list a list containing the potentially cyclic implements path |
| 12124 * @return {@code true} if and only if an error code is generated on the passe
d element | 12124 * @return {@code true} if and only if an error code is generated on the passe
d element |
| 12125 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE | 12125 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE |
| 12126 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS | 12126 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS |
| 12127 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEME
NTS | 12127 * @see CompileTimeErrorCode#RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEME
NTS |
| 12128 */ | 12128 */ |
| 12129 bool checkForRecursiveInterfaceInheritance(ClassElement classElt, List<ClassEl
ement> list) { | 12129 bool checkForRecursiveInterfaceInheritance(ClassElement classElt, List<ClassEl
ement> list) { |
| 12130 if (classElt == null) { | 12130 if (classElt == null) { |
| 12131 return false; | 12131 return false; |
| 12132 } | 12132 } |
| 12133 InterfaceType supertype2 = classElt.supertype; | 12133 InterfaceType supertype = classElt.supertype; |
| 12134 list.add(classElt); | 12134 list.add(classElt); |
| 12135 if (list.length != 1 && _enclosingClass == classElt) { | 12135 if (list.length != 1 && _enclosingClass == classElt) { |
| 12136 String enclosingClassName = _enclosingClass.displayName; | 12136 String enclosingClassName = _enclosingClass.displayName; |
| 12137 if (list.length > 2) { | 12137 if (list.length > 2) { |
| 12138 String separator = ", "; | 12138 String separator = ", "; |
| 12139 int listLength = list.length; | 12139 int listLength = list.length; |
| 12140 JavaStringBuilder builder = new JavaStringBuilder(); | 12140 JavaStringBuilder builder = new JavaStringBuilder(); |
| 12141 for (int i = 0; i < listLength; i++) { | 12141 for (int i = 0; i < listLength; i++) { |
| 12142 builder.append(list[i].displayName); | 12142 builder.append(list[i].displayName); |
| 12143 if (i != listLength - 1) { | 12143 if (i != listLength - 1) { |
| 12144 builder.append(separator); | 12144 builder.append(separator); |
| 12145 } | 12145 } |
| 12146 } | 12146 } |
| 12147 _errorReporter.reportError3(CompileTimeErrorCode.RECURSIVE_INTERFACE_INH
ERITANCE, _enclosingClass.nameOffset, enclosingClassName.length, [enclosingClass
Name, builder.toString()]); | 12147 _errorReporter.reportError3(CompileTimeErrorCode.RECURSIVE_INTERFACE_INH
ERITANCE, _enclosingClass.nameOffset, enclosingClassName.length, [enclosingClass
Name, builder.toString()]); |
| 12148 return true; | 12148 return true; |
| 12149 } else if (list.length == 2) { | 12149 } else if (list.length == 2) { |
| 12150 ErrorCode errorCode = supertype2 != null && _enclosingClass == supertype
2.element ? CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTEN
DS : CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS; | 12150 ErrorCode errorCode = supertype != null && _enclosingClass == supertype.
element ? CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS
: CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS; |
| 12151 _errorReporter.reportError3(errorCode, _enclosingClass.nameOffset, enclo
singClassName.length, [enclosingClassName]); | 12151 _errorReporter.reportError3(errorCode, _enclosingClass.nameOffset, enclo
singClassName.length, [enclosingClassName]); |
| 12152 return true; | 12152 return true; |
| 12153 } | 12153 } |
| 12154 } | 12154 } |
| 12155 for (int i = 1; i < list.length - 1; i++) { | 12155 for (int i = 1; i < list.length - 1; i++) { |
| 12156 if (classElt == list[i]) { | 12156 if (classElt == list[i]) { |
| 12157 list.removeAt(list.length - 1); | 12157 list.removeAt(list.length - 1); |
| 12158 return false; | 12158 return false; |
| 12159 } | 12159 } |
| 12160 } | 12160 } |
| 12161 List<ClassElement> interfaceElements; | 12161 List<ClassElement> interfaceElements; |
| 12162 List<InterfaceType> interfaceTypes = classElt.interfaces; | 12162 List<InterfaceType> interfaceTypes = classElt.interfaces; |
| 12163 if (supertype2 != null && !supertype2.isObject()) { | 12163 if (supertype != null && !supertype.isObject()) { |
| 12164 interfaceElements = new List<ClassElement>(interfaceTypes.length + 1); | 12164 interfaceElements = new List<ClassElement>(interfaceTypes.length + 1); |
| 12165 interfaceElements[0] = supertype2.element; | 12165 interfaceElements[0] = supertype.element; |
| 12166 for (int i = 0; i < interfaceTypes.length; i++) { | 12166 for (int i = 0; i < interfaceTypes.length; i++) { |
| 12167 interfaceElements[i + 1] = interfaceTypes[i].element; | 12167 interfaceElements[i + 1] = interfaceTypes[i].element; |
| 12168 } | 12168 } |
| 12169 } else { | 12169 } else { |
| 12170 interfaceElements = new List<ClassElement>(interfaceTypes.length); | 12170 interfaceElements = new List<ClassElement>(interfaceTypes.length); |
| 12171 for (int i = 0; i < interfaceTypes.length; i++) { | 12171 for (int i = 0; i < interfaceTypes.length; i++) { |
| 12172 interfaceElements[i] = interfaceTypes[i].element; | 12172 interfaceElements[i] = interfaceTypes[i].element; |
| 12173 } | 12173 } |
| 12174 } | 12174 } |
| 12175 for (ClassElement classElt2 in interfaceElements) { | 12175 for (ClassElement classElt2 in interfaceElements) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12222 * itself directly or indirectly. TODO(scheglov) | 12222 * itself directly or indirectly. TODO(scheglov) |
| 12223 * @param node the constructor declaration to evaluate | 12223 * @param node the constructor declaration to evaluate |
| 12224 * @return {@code true} if and only if an error code is generated on the passe
d node | 12224 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12225 * @see CompileTimeErrorCode#REDIRECT_TO_NON_CONST_CONSTRUCTOR | 12225 * @see CompileTimeErrorCode#REDIRECT_TO_NON_CONST_CONSTRUCTOR |
| 12226 */ | 12226 */ |
| 12227 bool checkForRedirectToNonConstConstructor(ConstructorDeclaration node) { | 12227 bool checkForRedirectToNonConstConstructor(ConstructorDeclaration node) { |
| 12228 ConstructorName redirectedConstructorNode = node.redirectedConstructor; | 12228 ConstructorName redirectedConstructorNode = node.redirectedConstructor; |
| 12229 if (redirectedConstructorNode == null) { | 12229 if (redirectedConstructorNode == null) { |
| 12230 return false; | 12230 return false; |
| 12231 } | 12231 } |
| 12232 ConstructorElement element2 = node.element; | 12232 ConstructorElement element = node.element; |
| 12233 if (element2 == null) { | 12233 if (element == null) { |
| 12234 return false; | 12234 return false; |
| 12235 } | 12235 } |
| 12236 if (!element2.isConst()) { | 12236 if (!element.isConst()) { |
| 12237 return false; | 12237 return false; |
| 12238 } | 12238 } |
| 12239 ConstructorElement redirectedConstructor2 = element2.redirectedConstructor; | 12239 ConstructorElement redirectedConstructor = element.redirectedConstructor; |
| 12240 if (redirectedConstructor2 == null) { | 12240 if (redirectedConstructor == null) { |
| 12241 return false; | 12241 return false; |
| 12242 } | 12242 } |
| 12243 if (redirectedConstructor2.isConst()) { | 12243 if (redirectedConstructor.isConst()) { |
| 12244 return false; | 12244 return false; |
| 12245 } | 12245 } |
| 12246 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST
RUCTOR, redirectedConstructorNode, []); | 12246 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST
RUCTOR, redirectedConstructorNode, []); |
| 12247 return true; | 12247 return true; |
| 12248 } | 12248 } |
| 12249 | 12249 |
| 12250 /** | 12250 /** |
| 12251 * This checks if the passed identifier is banned because it is part of the va
riable declaration | 12251 * This checks if the passed identifier is banned because it is part of the va
riable declaration |
| 12252 * with the same name. | 12252 * with the same name. |
| 12253 * @param node the identifier to evaluate | 12253 * @param node the identifier to evaluate |
| 12254 * @return {@code true} if and only if an error code is generated on the passe
d node | 12254 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12255 * @see CompileTimeErrorCode#REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER | 12255 * @see CompileTimeErrorCode#REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER |
| 12256 */ | 12256 */ |
| 12257 bool checkForReferenceToDeclaredVariableInInitializer(SimpleIdentifier node) { | 12257 bool checkForReferenceToDeclaredVariableInInitializer(SimpleIdentifier node) { |
| 12258 ASTNode parent2 = node.parent; | 12258 ASTNode parent = node.parent; |
| 12259 if (parent2 is PrefixedIdentifier) { | 12259 if (parent is PrefixedIdentifier) { |
| 12260 PrefixedIdentifier prefixedIdentifier = parent2 as PrefixedIdentifier; | 12260 PrefixedIdentifier prefixedIdentifier = parent as PrefixedIdentifier; |
| 12261 if (identical(prefixedIdentifier.identifier, node)) { | 12261 if (identical(prefixedIdentifier.identifier, node)) { |
| 12262 return false; | 12262 return false; |
| 12263 } | 12263 } |
| 12264 } | 12264 } |
| 12265 if (parent2 is PropertyAccess) { | 12265 if (parent is PropertyAccess) { |
| 12266 PropertyAccess propertyAccess = parent2 as PropertyAccess; | 12266 PropertyAccess propertyAccess = parent as PropertyAccess; |
| 12267 if (identical(propertyAccess.propertyName, node)) { | 12267 if (identical(propertyAccess.propertyName, node)) { |
| 12268 return false; | 12268 return false; |
| 12269 } | 12269 } |
| 12270 } | 12270 } |
| 12271 if (parent2 is MethodInvocation) { | 12271 if (parent is MethodInvocation) { |
| 12272 MethodInvocation methodInvocation = parent2 as MethodInvocation; | 12272 MethodInvocation methodInvocation = parent as MethodInvocation; |
| 12273 if (methodInvocation.target != null && identical(methodInvocation.methodNa
me, node)) { | 12273 if (methodInvocation.target != null && identical(methodInvocation.methodNa
me, node)) { |
| 12274 return false; | 12274 return false; |
| 12275 } | 12275 } |
| 12276 } | 12276 } |
| 12277 if (parent2 is ConstructorName) { | 12277 if (parent is ConstructorName) { |
| 12278 ConstructorName constructorName = parent2 as ConstructorName; | 12278 ConstructorName constructorName = parent as ConstructorName; |
| 12279 if (identical(constructorName.name, node)) { | 12279 if (identical(constructorName.name, node)) { |
| 12280 return false; | 12280 return false; |
| 12281 } | 12281 } |
| 12282 } | 12282 } |
| 12283 if (parent2 is Label) { | 12283 if (parent is Label) { |
| 12284 Label label = parent2 as Label; | 12284 Label label = parent as Label; |
| 12285 if (identical(label.label, node)) { | 12285 if (identical(label.label, node)) { |
| 12286 return false; | 12286 return false; |
| 12287 } | 12287 } |
| 12288 } | 12288 } |
| 12289 String name2 = node.name; | 12289 String name = node.name; |
| 12290 if (!_namesForReferenceToDeclaredVariableInInitializer.contains(name2)) { | 12290 if (!_namesForReferenceToDeclaredVariableInInitializer.contains(name)) { |
| 12291 return false; | 12291 return false; |
| 12292 } | 12292 } |
| 12293 _errorReporter.reportError2(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIA
BLE_IN_INITIALIZER, node, [name2]); | 12293 _errorReporter.reportError2(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIA
BLE_IN_INITIALIZER, node, [name]); |
| 12294 return true; | 12294 return true; |
| 12295 } | 12295 } |
| 12296 | 12296 |
| 12297 /** | 12297 /** |
| 12298 * This checks that the rethrow is inside of a catch clause. | 12298 * This checks that the rethrow is inside of a catch clause. |
| 12299 * @param node the rethrow expression to evaluate | 12299 * @param node the rethrow expression to evaluate |
| 12300 * @return {@code true} if and only if an error code is generated on the passe
d node | 12300 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12301 * @see CompileTimeErrorCode#RETHROW_OUTSIDE_CATCH | 12301 * @see CompileTimeErrorCode#RETHROW_OUTSIDE_CATCH |
| 12302 */ | 12302 */ |
| 12303 bool checkForRethrowOutsideCatch(RethrowExpression node) { | 12303 bool checkForRethrowOutsideCatch(RethrowExpression node) { |
| 12304 if (!_isInCatchClause) { | 12304 if (!_isInCatchClause) { |
| 12305 _errorReporter.reportError2(CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, no
de, []); | 12305 _errorReporter.reportError2(CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, no
de, []); |
| 12306 return true; | 12306 return true; |
| 12307 } | 12307 } |
| 12308 return false; | 12308 return false; |
| 12309 } | 12309 } |
| 12310 | 12310 |
| 12311 /** | 12311 /** |
| 12312 * This checks that if the given "target" is the type reference then the "name
" is not the | 12312 * This checks that if the given "target" is the type reference then the "name
" is not the |
| 12313 * reference to a instance member. | 12313 * reference to a instance member. |
| 12314 * @param target the target of the name access to evaluate | 12314 * @param target the target of the name access to evaluate |
| 12315 * @param name the accessed name to evaluate | 12315 * @param name the accessed name to evaluate |
| 12316 * @return {@code true} if and only if an error code is generated on the passe
d node | 12316 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12317 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER | 12317 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER |
| 12318 */ | 12318 */ |
| 12319 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier
name2) { | 12319 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier
name2) { |
| 12320 Element element2 = name2.element; | 12320 Element element = name2.element; |
| 12321 if (element2 is! ExecutableElement) { | 12321 if (element is! ExecutableElement) { |
| 12322 return false; | 12322 return false; |
| 12323 } | 12323 } |
| 12324 ExecutableElement memberElement = element2 as ExecutableElement; | 12324 ExecutableElement memberElement = element as ExecutableElement; |
| 12325 if (memberElement.isStatic()) { | 12325 if (memberElement.isStatic()) { |
| 12326 return false; | 12326 return false; |
| 12327 } | 12327 } |
| 12328 if (!isTypeReference(target)) { | 12328 if (!isTypeReference(target)) { |
| 12329 return false; | 12329 return false; |
| 12330 } | 12330 } |
| 12331 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB
ER, name2, [name2.name]); | 12331 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB
ER, name2, [name2.name]); |
| 12332 return true; | 12332 return true; |
| 12333 } | 12333 } |
| 12334 | 12334 |
| 12335 /** | 12335 /** |
| 12336 * This checks that the type of the passed 'switch' expression is assignable t
o the type of the | 12336 * This checks that the type of the passed 'switch' expression is assignable t
o the type of the |
| 12337 * 'case' members. | 12337 * 'case' members. |
| 12338 * @param node the 'switch' statement to evaluate | 12338 * @param node the 'switch' statement to evaluate |
| 12339 * @return {@code true} if and only if an error code is generated on the passe
d node | 12339 * @return {@code true} if and only if an error code is generated on the passe
d node |
| 12340 * @see StaticWarningCode#SWITCH_EXPRESSION_NOT_ASSIGNABLE | 12340 * @see StaticWarningCode#SWITCH_EXPRESSION_NOT_ASSIGNABLE |
| 12341 */ | 12341 */ |
| 12342 bool checkForSwitchExpressionNotAssignable(SwitchStatement node) { | 12342 bool checkForSwitchExpressionNotAssignable(SwitchStatement node) { |
| 12343 Expression expression2 = node.expression; | 12343 Expression expression = node.expression; |
| 12344 Type2 expressionType = getStaticType(expression2); | 12344 Type2 expressionType = getStaticType(expression); |
| 12345 if (expressionType == null) { | 12345 if (expressionType == null) { |
| 12346 return false; | 12346 return false; |
| 12347 } | 12347 } |
| 12348 NodeList<SwitchMember> members2 = node.members; | 12348 NodeList<SwitchMember> members = node.members; |
| 12349 for (SwitchMember switchMember in members2) { | 12349 for (SwitchMember switchMember in members) { |
| 12350 if (switchMember is! SwitchCase) { | 12350 if (switchMember is! SwitchCase) { |
| 12351 continue; | 12351 continue; |
| 12352 } | 12352 } |
| 12353 SwitchCase switchCase = switchMember as SwitchCase; | 12353 SwitchCase switchCase = switchMember as SwitchCase; |
| 12354 Expression caseExpression = switchCase.expression; | 12354 Expression caseExpression = switchCase.expression; |
| 12355 Type2 caseType = getStaticType(caseExpression); | 12355 Type2 caseType = getStaticType(caseExpression); |
| 12356 if (expressionType.isAssignableTo(caseType)) { | 12356 if (expressionType.isAssignableTo(caseType)) { |
| 12357 return false; | 12357 return false; |
| 12358 } | 12358 } |
| 12359 _errorReporter.reportError2(StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGN
ABLE, expression2, [expressionType, caseType]); | 12359 _errorReporter.reportError2(StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGN
ABLE, expression, [expressionType, caseType]); |
| 12360 return true; | 12360 return true; |
| 12361 } | 12361 } |
| 12362 return false; | 12362 return false; |
| 12363 } | 12363 } |
| 12364 | 12364 |
| 12365 /** | 12365 /** |
| 12366 * This verifies that the type arguments in the passed instance creation expre
ssion are all within | 12366 * This verifies that the type arguments in the passed instance creation expre
ssion are all within |
| 12367 * their bounds as specified by the class element where the constructor \[that
is being invoked\] is | 12367 * their bounds as specified by the class element where the constructor \[that
is being invoked\] is |
| 12368 * declared. | 12368 * declared. |
| 12369 * @param node the instance creation expression to evaluate | 12369 * @param node the instance creation expression to evaluate |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12442 bool checkForWrongNumberOfParametersForOperator(MethodDeclaration node) { | 12442 bool checkForWrongNumberOfParametersForOperator(MethodDeclaration node) { |
| 12443 FormalParameterList parameterList = node.parameters; | 12443 FormalParameterList parameterList = node.parameters; |
| 12444 if (parameterList == null) { | 12444 if (parameterList == null) { |
| 12445 return false; | 12445 return false; |
| 12446 } | 12446 } |
| 12447 int numParameters = parameterList.parameters.length; | 12447 int numParameters = parameterList.parameters.length; |
| 12448 SimpleIdentifier nameNode = node.name; | 12448 SimpleIdentifier nameNode = node.name; |
| 12449 if (nameNode == null) { | 12449 if (nameNode == null) { |
| 12450 return false; | 12450 return false; |
| 12451 } | 12451 } |
| 12452 String name2 = nameNode.name; | 12452 String name = nameNode.name; |
| 12453 int expected = -1; | 12453 int expected = -1; |
| 12454 if ("[]=" == name2) { | 12454 if ("[]=" == name) { |
| 12455 expected = 2; | 12455 expected = 2; |
| 12456 } else if ("<" == name2 || ">" == name2 || "<=" == name2 || ">=" == name2 ||
"==" == name2 || "+" == name2 || "/" == name2 || "~/" == name2 || "*" == name2
|| "%" == name2 || "|" == name2 || "^" == name2 || "&" == name2 || "<<" == name2
|| ">>" == name2 || "[]" == name2) { | 12456 } else if ("<" == name || ">" == name || "<=" == name || ">=" == name || "==
" == name || "+" == name || "/" == name || "~/" == name || "*" == name || "%" ==
name || "|" == name || "^" == name || "&" == name || "<<" == name || ">>" == na
me || "[]" == name) { |
| 12457 expected = 1; | 12457 expected = 1; |
| 12458 } else if ("~" == name2) { | 12458 } else if ("~" == name) { |
| 12459 expected = 0; | 12459 expected = 0; |
| 12460 } | 12460 } |
| 12461 if (expected != -1 && numParameters != expected) { | 12461 if (expected != -1 && numParameters != expected) { |
| 12462 _errorReporter.reportError2(CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETER
S_FOR_OPERATOR, nameNode, [name2, expected, numParameters]); | 12462 _errorReporter.reportError2(CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETER
S_FOR_OPERATOR, nameNode, [name, expected, numParameters]); |
| 12463 return true; | 12463 return true; |
| 12464 } | 12464 } |
| 12465 if ("-" == name2 && numParameters > 1) { | 12465 if ("-" == name && numParameters > 1) { |
| 12466 _errorReporter.reportError2(CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETER
S_FOR_OPERATOR_MINUS, nameNode, [numParameters]); | 12466 _errorReporter.reportError2(CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETER
S_FOR_OPERATOR_MINUS, nameNode, [numParameters]); |
| 12467 return true; | 12467 return true; |
| 12468 } | 12468 } |
| 12469 return false; | 12469 return false; |
| 12470 } | 12470 } |
| 12471 | 12471 |
| 12472 /** | 12472 /** |
| 12473 * This verifies if the passed setter parameter list have only one parameter. | 12473 * This verifies if the passed setter parameter list have only one parameter. |
| 12474 * <p> | 12474 * <p> |
| 12475 * This method assumes that the method declaration was tested to be a setter b
efore being called. | 12475 * This method assumes that the method declaration was tested to be a setter b
efore being called. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12555 } | 12555 } |
| 12556 | 12556 |
| 12557 /** | 12557 /** |
| 12558 * Return the variable element represented by the given expression, or {@code
null} if there is no | 12558 * Return the variable element represented by the given expression, or {@code
null} if there is no |
| 12559 * such element. | 12559 * such element. |
| 12560 * @param expression the expression whose element is to be returned | 12560 * @param expression the expression whose element is to be returned |
| 12561 * @return the variable element represented by the expression | 12561 * @return the variable element represented by the expression |
| 12562 */ | 12562 */ |
| 12563 VariableElement getVariableElement(Expression expression) { | 12563 VariableElement getVariableElement(Expression expression) { |
| 12564 if (expression is Identifier) { | 12564 if (expression is Identifier) { |
| 12565 Element element2 = ((expression as Identifier)).element; | 12565 Element element = ((expression as Identifier)).element; |
| 12566 if (element2 is VariableElement) { | 12566 if (element is VariableElement) { |
| 12567 return element2 as VariableElement; | 12567 return element as VariableElement; |
| 12568 } | 12568 } |
| 12569 } | 12569 } |
| 12570 return null; | 12570 return null; |
| 12571 } | 12571 } |
| 12572 | 12572 |
| 12573 /** | 12573 /** |
| 12574 * @return {@code true} if the given constructor redirects to itself, directly
or indirectly | 12574 * @return {@code true} if the given constructor redirects to itself, directly
or indirectly |
| 12575 */ | 12575 */ |
| 12576 bool hasRedirectingFactoryConstructorCycle(ConstructorElement element) { | 12576 bool hasRedirectingFactoryConstructorCycle(ConstructorElement element) { |
| 12577 Set<ConstructorElement> constructors = new Set<ConstructorElement>(); | 12577 Set<ConstructorElement> constructors = new Set<ConstructorElement>(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12708 | 12708 |
| 12709 /** | 12709 /** |
| 12710 * Answer the full name of the source associated with the compilation unit con
taining the given | 12710 * Answer the full name of the source associated with the compilation unit con
taining the given |
| 12711 * AST node. The returned value will have all {@link File#separatorChar} repla
ce by '/'. | 12711 * AST node. The returned value will have all {@link File#separatorChar} repla
ce by '/'. |
| 12712 * @param node the node (not {@code null}) | 12712 * @param node the node (not {@code null}) |
| 12713 * @return the full name or {@code null} if it could not be determined | 12713 * @return the full name or {@code null} if it could not be determined |
| 12714 */ | 12714 */ |
| 12715 String getSourceFullName(ASTNode node) { | 12715 String getSourceFullName(ASTNode node) { |
| 12716 CompilationUnit unit = node.getAncestor(CompilationUnit); | 12716 CompilationUnit unit = node.getAncestor(CompilationUnit); |
| 12717 if (unit != null) { | 12717 if (unit != null) { |
| 12718 CompilationUnitElement element2 = unit.element; | 12718 CompilationUnitElement element = unit.element; |
| 12719 if (element2 != null) { | 12719 if (element != null) { |
| 12720 Source librarySource = element2.source; | 12720 Source librarySource = element.source; |
| 12721 if (librarySource != null) { | 12721 if (librarySource != null) { |
| 12722 String fullName2 = librarySource.fullName; | 12722 String fullName = librarySource.fullName; |
| 12723 if (fullName2 != null) { | 12723 if (fullName != null) { |
| 12724 return fullName2.replaceAll(r'\', '/'); | 12724 return fullName.replaceAll(r'\', '/'); |
| 12725 } | 12725 } |
| 12726 } | 12726 } |
| 12727 } | 12727 } |
| 12728 } | 12728 } |
| 12729 return null; | 12729 return null; |
| 12730 } | 12730 } |
| 12731 } | 12731 } |
| 12732 /** | 12732 /** |
| 12733 * The enumeration {@code ResolverErrorCode} defines the error codes used for er
rors detected by the | 12733 * The enumeration {@code ResolverErrorCode} defines the error codes used for er
rors detected by the |
| 12734 * resolver. The convention for this class is for the name of the error code to
indicate the problem | 12734 * resolver. The convention for this class is for the name of the error code to
indicate the problem |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12767 this._type = type; | 12767 this._type = type; |
| 12768 this._message = message; | 12768 this._message = message; |
| 12769 } | 12769 } |
| 12770 ErrorSeverity get errorSeverity => _type.severity; | 12770 ErrorSeverity get errorSeverity => _type.severity; |
| 12771 String get message => _message; | 12771 String get message => _message; |
| 12772 ErrorType get type => _type; | 12772 ErrorType get type => _type; |
| 12773 int compareTo(ResolverErrorCode other) => ordinal - other.ordinal; | 12773 int compareTo(ResolverErrorCode other) => ordinal - other.ordinal; |
| 12774 int get hashCode => ordinal; | 12774 int get hashCode => ordinal; |
| 12775 String toString() => name; | 12775 String toString() => name; |
| 12776 } | 12776 } |
| OLD | NEW |