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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 SimpleIdentifier identifier = node.name; | 955 SimpleIdentifier identifier = node.name; |
956 String methodName = ""; | 956 String methodName = ""; |
957 if (identifier != null) { | 957 if (identifier != null) { |
958 methodName = identifier.name; | 958 methodName = identifier.name; |
959 } | 959 } |
960 TypeAnnotation returnType = node.returnType; | 960 TypeAnnotation returnType = node.returnType; |
961 if (node.isSetter || node.isGetter) { | 961 if (node.isSetter || node.isGetter) { |
962 _checkForMismatchedAccessorTypes(node, methodName); | 962 _checkForMismatchedAccessorTypes(node, methodName); |
963 } | 963 } |
964 if (node.isGetter) { | 964 if (node.isGetter) { |
965 _checkForVoidReturnType(node); | |
966 _checkForConflictingStaticGetterAndInstanceSetter(node); | 965 _checkForConflictingStaticGetterAndInstanceSetter(node); |
967 } else if (node.isSetter) { | 966 } else if (node.isSetter) { |
968 _checkForInvalidModifierOnBody( | 967 _checkForInvalidModifierOnBody( |
969 node.body, CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER); | 968 node.body, CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER); |
970 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters); | 969 _checkForWrongNumberOfParametersForSetter(node.name, node.parameters); |
971 _checkForNonVoidReturnTypeForSetter(returnType); | 970 _checkForNonVoidReturnTypeForSetter(returnType); |
972 _checkForConflictingStaticSetterAndInstanceMember(node); | 971 _checkForConflictingStaticSetterAndInstanceMember(node); |
973 } else if (node.isOperator) { | 972 } else if (node.isOperator) { |
974 _checkForOptionalParameterInOperator(node); | 973 _checkForOptionalParameterInOperator(node); |
975 _checkForWrongNumberOfParametersForOperator(node); | 974 _checkForWrongNumberOfParametersForOperator(node); |
(...skipping 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6034 } | 6033 } |
6035 } | 6034 } |
6036 } | 6035 } |
6037 // else { | 6036 // else { |
6038 // // TODO(jwren) Report error, constructor initializer variable is a top
level element | 6037 // // TODO(jwren) Report error, constructor initializer variable is a top
level element |
6039 // // (Either here or in ErrorVerifier.checkForAllFinalInitializedErrorCo
des) | 6038 // // (Either here or in ErrorVerifier.checkForAllFinalInitializedErrorCo
des) |
6040 // } | 6039 // } |
6041 } | 6040 } |
6042 | 6041 |
6043 /** | 6042 /** |
6044 * Verify that the given [getter] does not have a return type of 'void'. | |
6045 * | |
6046 * See [StaticWarningCode.VOID_RETURN_FOR_GETTER]. | |
6047 */ | |
6048 void _checkForVoidReturnType(MethodDeclaration getter) { | |
6049 TypeAnnotation returnType = getter.returnType; | |
6050 if (returnType is TypeName && returnType.name.name == "void") { | |
6051 _errorReporter.reportErrorForNode( | |
6052 StaticWarningCode.VOID_RETURN_FOR_GETTER, returnType); | |
6053 } | |
6054 } | |
6055 | |
6056 /** | |
6057 * Verify the given operator-method [declaration], has correct number of | 6043 * Verify the given operator-method [declaration], has correct number of |
6058 * parameters. | 6044 * parameters. |
6059 * | 6045 * |
6060 * This method assumes that the method declaration was tested to be an | 6046 * This method assumes that the method declaration was tested to be an |
6061 * operator declaration before being called. | 6047 * operator declaration before being called. |
6062 * | 6048 * |
6063 * See [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]. | 6049 * See [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]. |
6064 */ | 6050 */ |
6065 void _checkForWrongNumberOfParametersForOperator( | 6051 void _checkForWrongNumberOfParametersForOperator( |
6066 MethodDeclaration declaration) { | 6052 MethodDeclaration declaration) { |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7158 class _InvocationCollector extends RecursiveAstVisitor { | 7144 class _InvocationCollector extends RecursiveAstVisitor { |
7159 final List<String> superCalls = <String>[]; | 7145 final List<String> superCalls = <String>[]; |
7160 | 7146 |
7161 @override | 7147 @override |
7162 visitMethodInvocation(MethodInvocation node) { | 7148 visitMethodInvocation(MethodInvocation node) { |
7163 if (node.target is SuperExpression) { | 7149 if (node.target is SuperExpression) { |
7164 superCalls.add(node.methodName.name); | 7150 superCalls.add(node.methodName.name); |
7165 } | 7151 } |
7166 } | 7152 } |
7167 } | 7153 } |
OLD | NEW |