OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.generated.error_verifier; | 5 library analyzer.src.generated.error_verifier; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 6204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6215 final List<ConstantEvaluationTarget> requiredConstants = | 6215 final List<ConstantEvaluationTarget> requiredConstants = |
6216 <ConstantEvaluationTarget>[]; | 6216 <ConstantEvaluationTarget>[]; |
6217 | 6217 |
6218 /** | 6218 /** |
6219 * Initialize a newly created computer to compute required constants within | 6219 * Initialize a newly created computer to compute required constants within |
6220 * the given [source]. | 6220 * the given [source]. |
6221 */ | 6221 */ |
6222 RequiredConstantsComputer(this.source); | 6222 RequiredConstantsComputer(this.source); |
6223 | 6223 |
6224 @override | 6224 @override |
| 6225 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 6226 _checkForMissingRequiredParam( |
| 6227 node.staticInvokeType, node.argumentList, node); |
| 6228 return super.visitFunctionExpressionInvocation(node); |
| 6229 } |
| 6230 |
| 6231 @override |
6225 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 6232 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
6226 DartType type = node.constructorName.type.type; | 6233 DartType type = node.constructorName.type.type; |
6227 if (type is InterfaceType) { | 6234 if (type is InterfaceType) { |
6228 _checkForMissingRequiredParam( | 6235 _checkForMissingRequiredParam( |
6229 node.staticElement?.type, node.argumentList, node.constructorName); | 6236 node.staticElement?.type, node.argumentList, node.constructorName); |
6230 } | 6237 } |
6231 return super.visitInstanceCreationExpression(node); | 6238 return super.visitInstanceCreationExpression(node); |
6232 } | 6239 } |
6233 | 6240 |
6234 @override | 6241 @override |
6235 Object visitMethodInvocation(MethodInvocation node) { | 6242 Object visitMethodInvocation(MethodInvocation node) { |
6236 _checkForMissingRequiredParam( | 6243 _checkForMissingRequiredParam( |
6237 node.staticInvokeType, node.argumentList, node.methodName); | 6244 node.staticInvokeType, node.argumentList, node.methodName); |
6238 return super.visitMethodInvocation(node); | 6245 return super.visitMethodInvocation(node); |
6239 } | 6246 } |
6240 | 6247 |
| 6248 @override |
| 6249 Object visitRedirectingConstructorInvocation( |
| 6250 RedirectingConstructorInvocation node) { |
| 6251 DartType type = node.staticElement?.type; |
| 6252 if (type != null) { |
| 6253 _checkForMissingRequiredParam(type, node.argumentList, node); |
| 6254 } |
| 6255 return super.visitRedirectingConstructorInvocation(node); |
| 6256 } |
| 6257 |
| 6258 @override |
| 6259 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 6260 DartType type = node.staticElement?.type; |
| 6261 if (type != null) { |
| 6262 _checkForMissingRequiredParam(type, node.argumentList, node); |
| 6263 } |
| 6264 return super.visitSuperConstructorInvocation(node); |
| 6265 } |
| 6266 |
6241 void _checkForMissingRequiredParam( | 6267 void _checkForMissingRequiredParam( |
6242 DartType type, ArgumentList argumentList, AstNode node) { | 6268 DartType type, ArgumentList argumentList, AstNode node) { |
6243 if (type is FunctionType) { | 6269 if (type is FunctionType) { |
6244 for (ParameterElement parameter in type.parameters) { | 6270 for (ParameterElement parameter in type.parameters) { |
6245 if (parameter.parameterKind == ParameterKind.NAMED) { | 6271 if (parameter.parameterKind == ParameterKind.NAMED) { |
6246 ElementAnnotationImpl annotation = _getRequiredAnnotation(parameter); | 6272 ElementAnnotationImpl annotation = _getRequiredAnnotation(parameter); |
6247 if (annotation != null) { | 6273 if (annotation != null) { |
6248 String parameterName = parameter.name; | 6274 String parameterName = parameter.name; |
6249 if (!_containsNamedExpression(argumentList, parameterName)) { | 6275 if (!_containsNamedExpression(argumentList, parameterName)) { |
6250 requiredConstants.add(annotation); | 6276 requiredConstants.add(annotation); |
(...skipping 30 matching lines...) Expand all Loading... |
6281 class _InvocationCollector extends RecursiveAstVisitor { | 6307 class _InvocationCollector extends RecursiveAstVisitor { |
6282 final List<String> superCalls = <String>[]; | 6308 final List<String> superCalls = <String>[]; |
6283 | 6309 |
6284 @override | 6310 @override |
6285 visitMethodInvocation(MethodInvocation node) { | 6311 visitMethodInvocation(MethodInvocation node) { |
6286 if (node.target is SuperExpression) { | 6312 if (node.target is SuperExpression) { |
6287 superCalls.add(node.methodName.name); | 6313 superCalls.add(node.methodName.name); |
6288 } | 6314 } |
6289 } | 6315 } |
6290 } | 6316 } |
OLD | NEW |