| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.resolver; | 8 library engine.resolver; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 void _reportErrorForOffset(ErrorCode errorCode, int offset, int length, List<O
bject> arguments) { | 651 void _reportErrorForOffset(ErrorCode errorCode, int offset, int length, List<O
bject> arguments) { |
| 652 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); | 652 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 | 655 |
| 656 class RecursiveAstVisitor_AngularCompilationUnitBuilder_parseScopeProperties ext
ends RecursiveAstVisitor<Object> { | 656 class RecursiveAstVisitor_AngularCompilationUnitBuilder_parseScopeProperties ext
ends RecursiveAstVisitor<Object> { |
| 657 List<AngularScopePropertyElement> properties; | 657 List<AngularScopePropertyElement> properties; |
| 658 | 658 |
| 659 RecursiveAstVisitor_AngularCompilationUnitBuilder_parseScopeProperties(this.pr
operties) : super(); | 659 RecursiveAstVisitor_AngularCompilationUnitBuilder_parseScopeProperties(this.pr
operties) : super(); |
| 660 | 660 |
| 661 @override |
| 661 Object visitAssignmentExpression(AssignmentExpression node) { | 662 Object visitAssignmentExpression(AssignmentExpression node) { |
| 662 _addProperty(node); | 663 _addProperty(node); |
| 663 return super.visitAssignmentExpression(node); | 664 return super.visitAssignmentExpression(node); |
| 664 } | 665 } |
| 665 | 666 |
| 666 void _addProperty(AssignmentExpression node) { | 667 void _addProperty(AssignmentExpression node) { |
| 667 // try to find "name" in scope[name] | 668 // try to find "name" in scope[name] |
| 668 SimpleStringLiteral nameNode = _getNameNode(node.leftHandSide); | 669 SimpleStringLiteral nameNode = _getNameNode(node.leftHandSide); |
| 669 if (nameNode == null) { | 670 if (nameNode == null) { |
| 670 return; | 671 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 } | 723 } |
| 723 return false; | 724 return false; |
| 724 } | 725 } |
| 725 } | 726 } |
| 726 | 727 |
| 727 class RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews extends Recur
siveAstVisitor<Object> { | 728 class RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews extends Recur
siveAstVisitor<Object> { |
| 728 List<AngularViewElement> views; | 729 List<AngularViewElement> views; |
| 729 | 730 |
| 730 RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews(this.views) : sup
er(); | 731 RecursiveAstVisitor_AngularCompilationUnitBuilder_parseViews(this.views) : sup
er(); |
| 731 | 732 |
| 733 @override |
| 732 Object visitMethodInvocation(MethodInvocation node) { | 734 Object visitMethodInvocation(MethodInvocation node) { |
| 733 _addView(node); | 735 _addView(node); |
| 734 return super.visitMethodInvocation(node); | 736 return super.visitMethodInvocation(node); |
| 735 } | 737 } |
| 736 | 738 |
| 737 void _addView(MethodInvocation node) { | 739 void _addView(MethodInvocation node) { |
| 738 // only one argument | 740 // only one argument |
| 739 List<Expression> arguments = node.argumentList.arguments; | 741 List<Expression> arguments = node.argumentList.arguments; |
| 740 if (arguments.length != 1) { | 742 if (arguments.length != 1) { |
| 741 return; | 743 return; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 856 |
| 855 /** | 857 /** |
| 856 * Initialize a newly created element builder to build the elements for a comp
ilation unit. | 858 * Initialize a newly created element builder to build the elements for a comp
ilation unit. |
| 857 * | 859 * |
| 858 * @param initialHolder the element holder associated with the compilation uni
t being built | 860 * @param initialHolder the element holder associated with the compilation uni
t being built |
| 859 */ | 861 */ |
| 860 ElementBuilder(ElementHolder initialHolder) { | 862 ElementBuilder(ElementHolder initialHolder) { |
| 861 _currentHolder = initialHolder; | 863 _currentHolder = initialHolder; |
| 862 } | 864 } |
| 863 | 865 |
| 866 @override |
| 864 Object visitBlock(Block node) { | 867 Object visitBlock(Block node) { |
| 865 bool wasInField = _inFieldContext; | 868 bool wasInField = _inFieldContext; |
| 866 _inFieldContext = false; | 869 _inFieldContext = false; |
| 867 try { | 870 try { |
| 868 node.visitChildren(this); | 871 node.visitChildren(this); |
| 869 } finally { | 872 } finally { |
| 870 _inFieldContext = wasInField; | 873 _inFieldContext = wasInField; |
| 871 } | 874 } |
| 872 return null; | 875 return null; |
| 873 } | 876 } |
| 874 | 877 |
| 878 @override |
| 875 Object visitCatchClause(CatchClause node) { | 879 Object visitCatchClause(CatchClause node) { |
| 876 SimpleIdentifier exceptionParameter = node.exceptionParameter; | 880 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 877 if (exceptionParameter != null) { | 881 if (exceptionParameter != null) { |
| 878 LocalVariableElementImpl exception = new LocalVariableElementImpl(exceptio
nParameter); | 882 LocalVariableElementImpl exception = new LocalVariableElementImpl(exceptio
nParameter); |
| 879 _currentHolder.addLocalVariable(exception); | 883 _currentHolder.addLocalVariable(exception); |
| 880 exceptionParameter.staticElement = exception; | 884 exceptionParameter.staticElement = exception; |
| 881 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; | 885 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 882 if (stackTraceParameter != null) { | 886 if (stackTraceParameter != null) { |
| 883 LocalVariableElementImpl stackTrace = new LocalVariableElementImpl(stack
TraceParameter); | 887 LocalVariableElementImpl stackTrace = new LocalVariableElementImpl(stack
TraceParameter); |
| 884 _currentHolder.addLocalVariable(stackTrace); | 888 _currentHolder.addLocalVariable(stackTrace); |
| 885 stackTraceParameter.staticElement = stackTrace; | 889 stackTraceParameter.staticElement = stackTrace; |
| 886 } | 890 } |
| 887 } | 891 } |
| 888 return super.visitCatchClause(node); | 892 return super.visitCatchClause(node); |
| 889 } | 893 } |
| 890 | 894 |
| 895 @override |
| 891 Object visitClassDeclaration(ClassDeclaration node) { | 896 Object visitClassDeclaration(ClassDeclaration node) { |
| 892 ElementHolder holder = new ElementHolder(); | 897 ElementHolder holder = new ElementHolder(); |
| 893 _isValidMixin = true; | 898 _isValidMixin = true; |
| 894 _functionTypesToFix = new List<FunctionTypeImpl>(); | 899 _functionTypesToFix = new List<FunctionTypeImpl>(); |
| 895 // | 900 // |
| 896 // Process field declarations before constructors and methods so that field
formal parameters | 901 // Process field declarations before constructors and methods so that field
formal parameters |
| 897 // can be correctly resolved to their fields. | 902 // can be correctly resolved to their fields. |
| 898 // | 903 // |
| 899 ElementHolder previousHolder = _currentHolder; | 904 ElementHolder previousHolder = _currentHolder; |
| 900 _currentHolder = holder; | 905 _currentHolder = holder; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 _functionTypesToFix[i].typeArguments = typeArguments; | 940 _functionTypesToFix[i].typeArguments = typeArguments; |
| 936 } | 941 } |
| 937 _functionTypesToFix = null; | 942 _functionTypesToFix = null; |
| 938 _currentHolder.addType(element); | 943 _currentHolder.addType(element); |
| 939 className.staticElement = element; | 944 className.staticElement = element; |
| 940 _fieldMap = null; | 945 _fieldMap = null; |
| 941 holder.validate(); | 946 holder.validate(); |
| 942 return null; | 947 return null; |
| 943 } | 948 } |
| 944 | 949 |
| 950 @override |
| 945 Object visitClassTypeAlias(ClassTypeAlias node) { | 951 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 946 ElementHolder holder = new ElementHolder(); | 952 ElementHolder holder = new ElementHolder(); |
| 947 _functionTypesToFix = new List<FunctionTypeImpl>(); | 953 _functionTypesToFix = new List<FunctionTypeImpl>(); |
| 948 _visitChildren(holder, node); | 954 _visitChildren(holder, node); |
| 949 SimpleIdentifier className = node.name; | 955 SimpleIdentifier className = node.name; |
| 950 ClassElementImpl element = new ClassElementImpl(className); | 956 ClassElementImpl element = new ClassElementImpl(className); |
| 951 element.abstract = node.abstractKeyword != null; | 957 element.abstract = node.abstractKeyword != null; |
| 952 element.typedef = true; | 958 element.typedef = true; |
| 953 List<TypeParameterElement> typeParameters = holder.typeParameters; | 959 List<TypeParameterElement> typeParameters = holder.typeParameters; |
| 954 element.typeParameters = typeParameters; | 960 element.typeParameters = typeParameters; |
| 955 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); | 961 List<DartType> typeArguments = _createTypeParameterTypes(typeParameters); |
| 956 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); | 962 InterfaceTypeImpl interfaceType = new InterfaceTypeImpl.con1(element); |
| 957 interfaceType.typeArguments = typeArguments; | 963 interfaceType.typeArguments = typeArguments; |
| 958 element.type = interfaceType; | 964 element.type = interfaceType; |
| 959 // set default constructor | 965 // set default constructor |
| 960 element.constructors = _createDefaultConstructors(interfaceType); | 966 element.constructors = _createDefaultConstructors(interfaceType); |
| 961 for (FunctionTypeImpl functionType in _functionTypesToFix) { | 967 for (FunctionTypeImpl functionType in _functionTypesToFix) { |
| 962 functionType.typeArguments = typeArguments; | 968 functionType.typeArguments = typeArguments; |
| 963 } | 969 } |
| 964 _functionTypesToFix = null; | 970 _functionTypesToFix = null; |
| 965 _currentHolder.addType(element); | 971 _currentHolder.addType(element); |
| 966 className.staticElement = element; | 972 className.staticElement = element; |
| 967 holder.validate(); | 973 holder.validate(); |
| 968 return null; | 974 return null; |
| 969 } | 975 } |
| 970 | 976 |
| 977 @override |
| 971 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 978 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 972 _isValidMixin = false; | 979 _isValidMixin = false; |
| 973 ElementHolder holder = new ElementHolder(); | 980 ElementHolder holder = new ElementHolder(); |
| 974 bool wasInFunction = _inFunction; | 981 bool wasInFunction = _inFunction; |
| 975 _inFunction = true; | 982 _inFunction = true; |
| 976 try { | 983 try { |
| 977 _visitChildren(holder, node); | 984 _visitChildren(holder, node); |
| 978 } finally { | 985 } finally { |
| 979 _inFunction = wasInFunction; | 986 _inFunction = wasInFunction; |
| 980 } | 987 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 995 if (returnType != null) { | 1002 if (returnType != null) { |
| 996 element.nameOffset = returnType.offset; | 1003 element.nameOffset = returnType.offset; |
| 997 } | 1004 } |
| 998 } else { | 1005 } else { |
| 999 constructorName.staticElement = element; | 1006 constructorName.staticElement = element; |
| 1000 } | 1007 } |
| 1001 holder.validate(); | 1008 holder.validate(); |
| 1002 return null; | 1009 return null; |
| 1003 } | 1010 } |
| 1004 | 1011 |
| 1012 @override |
| 1005 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 1013 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 1006 SimpleIdentifier variableName = node.identifier; | 1014 SimpleIdentifier variableName = node.identifier; |
| 1007 sc.Token keyword = node.keyword; | 1015 sc.Token keyword = node.keyword; |
| 1008 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); | 1016 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); |
| 1009 ForEachStatement statement = node.parent as ForEachStatement; | 1017 ForEachStatement statement = node.parent as ForEachStatement; |
| 1010 int declarationEnd = node.offset + node.length; | 1018 int declarationEnd = node.offset + node.length; |
| 1011 int statementEnd = statement.offset + statement.length; | 1019 int statementEnd = statement.offset + statement.length; |
| 1012 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); | 1020 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); |
| 1013 element.const3 = _matches(keyword, sc.Keyword.CONST); | 1021 element.const3 = _matches(keyword, sc.Keyword.CONST); |
| 1014 element.final2 = _matches(keyword, sc.Keyword.FINAL); | 1022 element.final2 = _matches(keyword, sc.Keyword.FINAL); |
| 1015 _currentHolder.addLocalVariable(element); | 1023 _currentHolder.addLocalVariable(element); |
| 1016 variableName.staticElement = element; | 1024 variableName.staticElement = element; |
| 1017 return super.visitDeclaredIdentifier(node); | 1025 return super.visitDeclaredIdentifier(node); |
| 1018 } | 1026 } |
| 1019 | 1027 |
| 1028 @override |
| 1020 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 1029 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 1021 ElementHolder holder = new ElementHolder(); | 1030 ElementHolder holder = new ElementHolder(); |
| 1022 NormalFormalParameter normalParameter = node.parameter; | 1031 NormalFormalParameter normalParameter = node.parameter; |
| 1023 SimpleIdentifier parameterName = normalParameter.identifier; | 1032 SimpleIdentifier parameterName = normalParameter.identifier; |
| 1024 ParameterElementImpl parameter; | 1033 ParameterElementImpl parameter; |
| 1025 if (normalParameter is FieldFormalParameter) { | 1034 if (normalParameter is FieldFormalParameter) { |
| 1026 parameter = new DefaultFieldFormalParameterElementImpl(parameterName); | 1035 parameter = new DefaultFieldFormalParameterElementImpl(parameterName); |
| 1027 FieldElement field = _fieldMap == null ? null : _fieldMap[parameterName.na
me]; | 1036 FieldElement field = _fieldMap == null ? null : _fieldMap[parameterName.na
me]; |
| 1028 if (field != null) { | 1037 if (field != null) { |
| 1029 (parameter as DefaultFieldFormalParameterElementImpl).field = field; | 1038 (parameter as DefaultFieldFormalParameterElementImpl).field = field; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1049 } | 1058 } |
| 1050 // visible range | 1059 // visible range |
| 1051 _setParameterVisibleRange(node, parameter); | 1060 _setParameterVisibleRange(node, parameter); |
| 1052 _currentHolder.addParameter(parameter); | 1061 _currentHolder.addParameter(parameter); |
| 1053 parameterName.staticElement = parameter; | 1062 parameterName.staticElement = parameter; |
| 1054 normalParameter.accept(this); | 1063 normalParameter.accept(this); |
| 1055 holder.validate(); | 1064 holder.validate(); |
| 1056 return null; | 1065 return null; |
| 1057 } | 1066 } |
| 1058 | 1067 |
| 1068 @override |
| 1059 Object visitFieldDeclaration(FieldDeclaration node) { | 1069 Object visitFieldDeclaration(FieldDeclaration node) { |
| 1060 bool wasInField = _inFieldContext; | 1070 bool wasInField = _inFieldContext; |
| 1061 _inFieldContext = true; | 1071 _inFieldContext = true; |
| 1062 try { | 1072 try { |
| 1063 node.visitChildren(this); | 1073 node.visitChildren(this); |
| 1064 } finally { | 1074 } finally { |
| 1065 _inFieldContext = wasInField; | 1075 _inFieldContext = wasInField; |
| 1066 } | 1076 } |
| 1067 return null; | 1077 return null; |
| 1068 } | 1078 } |
| 1069 | 1079 |
| 1080 @override |
| 1070 Object visitFieldFormalParameter(FieldFormalParameter node) { | 1081 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 1071 if (node.parent is! DefaultFormalParameter) { | 1082 if (node.parent is! DefaultFormalParameter) { |
| 1072 SimpleIdentifier parameterName = node.identifier; | 1083 SimpleIdentifier parameterName = node.identifier; |
| 1073 FieldElement field = _fieldMap == null ? null : _fieldMap[parameterName.na
me]; | 1084 FieldElement field = _fieldMap == null ? null : _fieldMap[parameterName.na
me]; |
| 1074 FieldFormalParameterElementImpl parameter = new FieldFormalParameterElemen
tImpl(parameterName); | 1085 FieldFormalParameterElementImpl parameter = new FieldFormalParameterElemen
tImpl(parameterName); |
| 1075 parameter.const3 = node.isConst; | 1086 parameter.const3 = node.isConst; |
| 1076 parameter.final2 = node.isFinal; | 1087 parameter.final2 = node.isFinal; |
| 1077 parameter.parameterKind = node.kind; | 1088 parameter.parameterKind = node.kind; |
| 1078 if (field != null) { | 1089 if (field != null) { |
| 1079 parameter.field = field; | 1090 parameter.field = field; |
| 1080 } | 1091 } |
| 1081 _currentHolder.addParameter(parameter); | 1092 _currentHolder.addParameter(parameter); |
| 1082 parameterName.staticElement = parameter; | 1093 parameterName.staticElement = parameter; |
| 1083 } | 1094 } |
| 1084 // | 1095 // |
| 1085 // The children of this parameter include any parameters defined on the type
of this parameter. | 1096 // The children of this parameter include any parameters defined on the type
of this parameter. |
| 1086 // | 1097 // |
| 1087 ElementHolder holder = new ElementHolder(); | 1098 ElementHolder holder = new ElementHolder(); |
| 1088 _visitChildren(holder, node); | 1099 _visitChildren(holder, node); |
| 1089 (node.element as ParameterElementImpl).parameters = holder.parameters; | 1100 (node.element as ParameterElementImpl).parameters = holder.parameters; |
| 1090 holder.validate(); | 1101 holder.validate(); |
| 1091 return null; | 1102 return null; |
| 1092 } | 1103 } |
| 1093 | 1104 |
| 1105 @override |
| 1094 Object visitFunctionDeclaration(FunctionDeclaration node) { | 1106 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 1095 FunctionExpression expression = node.functionExpression; | 1107 FunctionExpression expression = node.functionExpression; |
| 1096 if (expression != null) { | 1108 if (expression != null) { |
| 1097 ElementHolder holder = new ElementHolder(); | 1109 ElementHolder holder = new ElementHolder(); |
| 1098 bool wasInFunction = _inFunction; | 1110 bool wasInFunction = _inFunction; |
| 1099 _inFunction = true; | 1111 _inFunction = true; |
| 1100 try { | 1112 try { |
| 1101 _visitChildren(holder, expression); | 1113 _visitChildren(holder, expression); |
| 1102 } finally { | 1114 } finally { |
| 1103 _inFunction = wasInFunction; | 1115 _inFunction = wasInFunction; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 _currentHolder.addAccessor(setter); | 1173 _currentHolder.addAccessor(setter); |
| 1162 expression.element = setter; | 1174 expression.element = setter; |
| 1163 propertyNameNode.staticElement = setter; | 1175 propertyNameNode.staticElement = setter; |
| 1164 } | 1176 } |
| 1165 } | 1177 } |
| 1166 holder.validate(); | 1178 holder.validate(); |
| 1167 } | 1179 } |
| 1168 return null; | 1180 return null; |
| 1169 } | 1181 } |
| 1170 | 1182 |
| 1183 @override |
| 1171 Object visitFunctionExpression(FunctionExpression node) { | 1184 Object visitFunctionExpression(FunctionExpression node) { |
| 1172 ElementHolder holder = new ElementHolder(); | 1185 ElementHolder holder = new ElementHolder(); |
| 1173 bool wasInFunction = _inFunction; | 1186 bool wasInFunction = _inFunction; |
| 1174 _inFunction = true; | 1187 _inFunction = true; |
| 1175 try { | 1188 try { |
| 1176 _visitChildren(holder, node); | 1189 _visitChildren(holder, node); |
| 1177 } finally { | 1190 } finally { |
| 1178 _inFunction = wasInFunction; | 1191 _inFunction = wasInFunction; |
| 1179 } | 1192 } |
| 1180 FunctionElementImpl element = new FunctionElementImpl.con2(node.beginToken.o
ffset); | 1193 FunctionElementImpl element = new FunctionElementImpl.con2(node.beginToken.o
ffset); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1194 if (_functionTypesToFix != null) { | 1207 if (_functionTypesToFix != null) { |
| 1195 _functionTypesToFix.add(type); | 1208 _functionTypesToFix.add(type); |
| 1196 } | 1209 } |
| 1197 element.type = type; | 1210 element.type = type; |
| 1198 _currentHolder.addFunction(element); | 1211 _currentHolder.addFunction(element); |
| 1199 node.element = element; | 1212 node.element = element; |
| 1200 holder.validate(); | 1213 holder.validate(); |
| 1201 return null; | 1214 return null; |
| 1202 } | 1215 } |
| 1203 | 1216 |
| 1217 @override |
| 1204 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 1218 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 1205 ElementHolder holder = new ElementHolder(); | 1219 ElementHolder holder = new ElementHolder(); |
| 1206 _visitChildren(holder, node); | 1220 _visitChildren(holder, node); |
| 1207 SimpleIdentifier aliasName = node.name; | 1221 SimpleIdentifier aliasName = node.name; |
| 1208 List<ParameterElement> parameters = holder.parameters; | 1222 List<ParameterElement> parameters = holder.parameters; |
| 1209 List<TypeParameterElement> typeParameters = holder.typeParameters; | 1223 List<TypeParameterElement> typeParameters = holder.typeParameters; |
| 1210 FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(alia
sName); | 1224 FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(alia
sName); |
| 1211 element.parameters = parameters; | 1225 element.parameters = parameters; |
| 1212 element.typeParameters = typeParameters; | 1226 element.typeParameters = typeParameters; |
| 1213 FunctionTypeImpl type = new FunctionTypeImpl.con2(element); | 1227 FunctionTypeImpl type = new FunctionTypeImpl.con2(element); |
| 1214 type.typeArguments = _createTypeParameterTypes(typeParameters); | 1228 type.typeArguments = _createTypeParameterTypes(typeParameters); |
| 1215 element.type = type; | 1229 element.type = type; |
| 1216 _currentHolder.addTypeAlias(element); | 1230 _currentHolder.addTypeAlias(element); |
| 1217 aliasName.staticElement = element; | 1231 aliasName.staticElement = element; |
| 1218 holder.validate(); | 1232 holder.validate(); |
| 1219 return null; | 1233 return null; |
| 1220 } | 1234 } |
| 1221 | 1235 |
| 1236 @override |
| 1222 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 1237 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 1223 if (node.parent is! DefaultFormalParameter) { | 1238 if (node.parent is! DefaultFormalParameter) { |
| 1224 SimpleIdentifier parameterName = node.identifier; | 1239 SimpleIdentifier parameterName = node.identifier; |
| 1225 ParameterElementImpl parameter = new ParameterElementImpl.con1(parameterNa
me); | 1240 ParameterElementImpl parameter = new ParameterElementImpl.con1(parameterNa
me); |
| 1226 parameter.parameterKind = node.kind; | 1241 parameter.parameterKind = node.kind; |
| 1227 _setParameterVisibleRange(node, parameter); | 1242 _setParameterVisibleRange(node, parameter); |
| 1228 _currentHolder.addParameter(parameter); | 1243 _currentHolder.addParameter(parameter); |
| 1229 parameterName.staticElement = parameter; | 1244 parameterName.staticElement = parameter; |
| 1230 } | 1245 } |
| 1231 // | 1246 // |
| 1232 // The children of this parameter include any parameters defined on the type
of this parameter. | 1247 // The children of this parameter include any parameters defined on the type
of this parameter. |
| 1233 // | 1248 // |
| 1234 ElementHolder holder = new ElementHolder(); | 1249 ElementHolder holder = new ElementHolder(); |
| 1235 _visitChildren(holder, node); | 1250 _visitChildren(holder, node); |
| 1236 (node.element as ParameterElementImpl).parameters = holder.parameters; | 1251 (node.element as ParameterElementImpl).parameters = holder.parameters; |
| 1237 holder.validate(); | 1252 holder.validate(); |
| 1238 return null; | 1253 return null; |
| 1239 } | 1254 } |
| 1240 | 1255 |
| 1256 @override |
| 1241 Object visitLabeledStatement(LabeledStatement node) { | 1257 Object visitLabeledStatement(LabeledStatement node) { |
| 1242 bool onSwitchStatement = node.statement is SwitchStatement; | 1258 bool onSwitchStatement = node.statement is SwitchStatement; |
| 1243 for (Label label in node.labels) { | 1259 for (Label label in node.labels) { |
| 1244 SimpleIdentifier labelName = label.label; | 1260 SimpleIdentifier labelName = label.label; |
| 1245 LabelElementImpl element = new LabelElementImpl(labelName, onSwitchStateme
nt, false); | 1261 LabelElementImpl element = new LabelElementImpl(labelName, onSwitchStateme
nt, false); |
| 1246 _currentHolder.addLabel(element); | 1262 _currentHolder.addLabel(element); |
| 1247 labelName.staticElement = element; | 1263 labelName.staticElement = element; |
| 1248 } | 1264 } |
| 1249 return super.visitLabeledStatement(node); | 1265 return super.visitLabeledStatement(node); |
| 1250 } | 1266 } |
| 1251 | 1267 |
| 1268 @override |
| 1252 Object visitMethodDeclaration(MethodDeclaration node) { | 1269 Object visitMethodDeclaration(MethodDeclaration node) { |
| 1253 ElementHolder holder = new ElementHolder(); | 1270 ElementHolder holder = new ElementHolder(); |
| 1254 bool wasInFunction = _inFunction; | 1271 bool wasInFunction = _inFunction; |
| 1255 _inFunction = true; | 1272 _inFunction = true; |
| 1256 try { | 1273 try { |
| 1257 _visitChildren(holder, node); | 1274 _visitChildren(holder, node); |
| 1258 } finally { | 1275 } finally { |
| 1259 _inFunction = wasInFunction; | 1276 _inFunction = wasInFunction; |
| 1260 } | 1277 } |
| 1261 bool isStatic = node.isStatic; | 1278 bool isStatic = node.isStatic; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 field.setter = setter; | 1328 field.setter = setter; |
| 1312 field.final2 = false; | 1329 field.final2 = false; |
| 1313 _currentHolder.addAccessor(setter); | 1330 _currentHolder.addAccessor(setter); |
| 1314 propertyNameNode.staticElement = setter; | 1331 propertyNameNode.staticElement = setter; |
| 1315 } | 1332 } |
| 1316 } | 1333 } |
| 1317 holder.validate(); | 1334 holder.validate(); |
| 1318 return null; | 1335 return null; |
| 1319 } | 1336 } |
| 1320 | 1337 |
| 1338 @override |
| 1321 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 1339 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 1322 if (node.parent is! DefaultFormalParameter) { | 1340 if (node.parent is! DefaultFormalParameter) { |
| 1323 SimpleIdentifier parameterName = node.identifier; | 1341 SimpleIdentifier parameterName = node.identifier; |
| 1324 ParameterElementImpl parameter = new ParameterElementImpl.con1(parameterNa
me); | 1342 ParameterElementImpl parameter = new ParameterElementImpl.con1(parameterNa
me); |
| 1325 parameter.const3 = node.isConst; | 1343 parameter.const3 = node.isConst; |
| 1326 parameter.final2 = node.isFinal; | 1344 parameter.final2 = node.isFinal; |
| 1327 parameter.parameterKind = node.kind; | 1345 parameter.parameterKind = node.kind; |
| 1328 _setParameterVisibleRange(node, parameter); | 1346 _setParameterVisibleRange(node, parameter); |
| 1329 _currentHolder.addParameter(parameter); | 1347 _currentHolder.addParameter(parameter); |
| 1330 parameterName.staticElement = parameter; | 1348 parameterName.staticElement = parameter; |
| 1331 } | 1349 } |
| 1332 return super.visitSimpleFormalParameter(node); | 1350 return super.visitSimpleFormalParameter(node); |
| 1333 } | 1351 } |
| 1334 | 1352 |
| 1353 @override |
| 1335 Object visitSuperExpression(SuperExpression node) { | 1354 Object visitSuperExpression(SuperExpression node) { |
| 1336 _isValidMixin = false; | 1355 _isValidMixin = false; |
| 1337 return super.visitSuperExpression(node); | 1356 return super.visitSuperExpression(node); |
| 1338 } | 1357 } |
| 1339 | 1358 |
| 1359 @override |
| 1340 Object visitSwitchCase(SwitchCase node) { | 1360 Object visitSwitchCase(SwitchCase node) { |
| 1341 for (Label label in node.labels) { | 1361 for (Label label in node.labels) { |
| 1342 SimpleIdentifier labelName = label.label; | 1362 SimpleIdentifier labelName = label.label; |
| 1343 LabelElementImpl element = new LabelElementImpl(labelName, false, true); | 1363 LabelElementImpl element = new LabelElementImpl(labelName, false, true); |
| 1344 _currentHolder.addLabel(element); | 1364 _currentHolder.addLabel(element); |
| 1345 labelName.staticElement = element; | 1365 labelName.staticElement = element; |
| 1346 } | 1366 } |
| 1347 return super.visitSwitchCase(node); | 1367 return super.visitSwitchCase(node); |
| 1348 } | 1368 } |
| 1349 | 1369 |
| 1370 @override |
| 1350 Object visitSwitchDefault(SwitchDefault node) { | 1371 Object visitSwitchDefault(SwitchDefault node) { |
| 1351 for (Label label in node.labels) { | 1372 for (Label label in node.labels) { |
| 1352 SimpleIdentifier labelName = label.label; | 1373 SimpleIdentifier labelName = label.label; |
| 1353 LabelElementImpl element = new LabelElementImpl(labelName, false, true); | 1374 LabelElementImpl element = new LabelElementImpl(labelName, false, true); |
| 1354 _currentHolder.addLabel(element); | 1375 _currentHolder.addLabel(element); |
| 1355 labelName.staticElement = element; | 1376 labelName.staticElement = element; |
| 1356 } | 1377 } |
| 1357 return super.visitSwitchDefault(node); | 1378 return super.visitSwitchDefault(node); |
| 1358 } | 1379 } |
| 1359 | 1380 |
| 1381 @override |
| 1360 Object visitTypeParameter(TypeParameter node) { | 1382 Object visitTypeParameter(TypeParameter node) { |
| 1361 SimpleIdentifier parameterName = node.name; | 1383 SimpleIdentifier parameterName = node.name; |
| 1362 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(parame
terName); | 1384 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(parame
terName); |
| 1363 TypeParameterTypeImpl typeParameterType = new TypeParameterTypeImpl(typePara
meter); | 1385 TypeParameterTypeImpl typeParameterType = new TypeParameterTypeImpl(typePara
meter); |
| 1364 typeParameter.type = typeParameterType; | 1386 typeParameter.type = typeParameterType; |
| 1365 _currentHolder.addTypeParameter(typeParameter); | 1387 _currentHolder.addTypeParameter(typeParameter); |
| 1366 parameterName.staticElement = typeParameter; | 1388 parameterName.staticElement = typeParameter; |
| 1367 return super.visitTypeParameter(node); | 1389 return super.visitTypeParameter(node); |
| 1368 } | 1390 } |
| 1369 | 1391 |
| 1392 @override |
| 1370 Object visitVariableDeclaration(VariableDeclaration node) { | 1393 Object visitVariableDeclaration(VariableDeclaration node) { |
| 1371 sc.Token keyword = (node.parent as VariableDeclarationList).keyword; | 1394 sc.Token keyword = (node.parent as VariableDeclarationList).keyword; |
| 1372 bool isConst = _matches(keyword, sc.Keyword.CONST); | 1395 bool isConst = _matches(keyword, sc.Keyword.CONST); |
| 1373 bool isFinal = _matches(keyword, sc.Keyword.FINAL); | 1396 bool isFinal = _matches(keyword, sc.Keyword.FINAL); |
| 1374 bool hasInitializer = node.initializer != null; | 1397 bool hasInitializer = node.initializer != null; |
| 1375 VariableElementImpl element; | 1398 VariableElementImpl element; |
| 1376 if (_inFieldContext) { | 1399 if (_inFieldContext) { |
| 1377 SimpleIdentifier fieldName = node.name; | 1400 SimpleIdentifier fieldName = node.name; |
| 1378 FieldElementImpl field; | 1401 FieldElementImpl field; |
| 1379 if (isConst && hasInitializer) { | 1402 if (isConst && hasInitializer) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 } | 1607 } |
| 1585 } | 1608 } |
| 1586 | 1609 |
| 1587 class UnifyingAstVisitor_ElementBuilder_visitClassDeclaration extends UnifyingAs
tVisitor<Object> { | 1610 class UnifyingAstVisitor_ElementBuilder_visitClassDeclaration extends UnifyingAs
tVisitor<Object> { |
| 1588 final ElementBuilder ElementBuilder_this; | 1611 final ElementBuilder ElementBuilder_this; |
| 1589 | 1612 |
| 1590 List<ClassMember> nonFields; | 1613 List<ClassMember> nonFields; |
| 1591 | 1614 |
| 1592 UnifyingAstVisitor_ElementBuilder_visitClassDeclaration(this.ElementBuilder_th
is, this.nonFields) : super(); | 1615 UnifyingAstVisitor_ElementBuilder_visitClassDeclaration(this.ElementBuilder_th
is, this.nonFields) : super(); |
| 1593 | 1616 |
| 1617 @override |
| 1594 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 1618 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 1595 nonFields.add(node); | 1619 nonFields.add(node); |
| 1596 return null; | 1620 return null; |
| 1597 } | 1621 } |
| 1598 | 1622 |
| 1623 @override |
| 1599 Object visitMethodDeclaration(MethodDeclaration node) { | 1624 Object visitMethodDeclaration(MethodDeclaration node) { |
| 1600 nonFields.add(node); | 1625 nonFields.add(node); |
| 1601 return null; | 1626 return null; |
| 1602 } | 1627 } |
| 1603 | 1628 |
| 1629 @override |
| 1604 Object visitNode(AstNode node) => node.accept(ElementBuilder_this); | 1630 Object visitNode(AstNode node) => node.accept(ElementBuilder_this); |
| 1605 } | 1631 } |
| 1606 | 1632 |
| 1607 /** | 1633 /** |
| 1608 * Instances of the class `ElementHolder` hold on to elements created while trav
ersing an AST | 1634 * Instances of the class `ElementHolder` hold on to elements created while trav
ersing an AST |
| 1609 * structure so that they can be accessed when creating their enclosing element. | 1635 * structure so that they can be accessed when creating their enclosing element. |
| 1610 */ | 1636 */ |
| 1611 class ElementHolder { | 1637 class ElementHolder { |
| 1612 List<PropertyAccessorElement> _accessors; | 1638 List<PropertyAccessorElement> _accessors; |
| 1613 | 1639 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 */ | 2050 */ |
| 2025 RecordingErrorListener get errorListener => _errorListener; | 2051 RecordingErrorListener get errorListener => _errorListener; |
| 2026 | 2052 |
| 2027 /** | 2053 /** |
| 2028 * Return an array containing information about all of the libraries that were
resolved. | 2054 * Return an array containing information about all of the libraries that were
resolved. |
| 2029 * | 2055 * |
| 2030 * @return an array containing the libraries that were resolved | 2056 * @return an array containing the libraries that were resolved |
| 2031 */ | 2057 */ |
| 2032 Set<Library> get resolvedLibraries => _resolvedLibraries; | 2058 Set<Library> get resolvedLibraries => _resolvedLibraries; |
| 2033 | 2059 |
| 2060 @override |
| 2034 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { | 2061 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { |
| 2035 if (_parentNodes.contains(node)) { | 2062 if (_parentNodes.contains(node)) { |
| 2036 return _reportCircularity(node); | 2063 return _reportCircularity(node); |
| 2037 } | 2064 } |
| 2038 _parentNodes.add(node); | 2065 _parentNodes.add(node); |
| 2039 try { | 2066 try { |
| 2040 Source htmlSource = _htmlElement.source; | 2067 Source htmlSource = _htmlElement.source; |
| 2041 ht.XmlAttributeNode scriptAttribute = _getScriptSourcePath(node); | 2068 ht.XmlAttributeNode scriptAttribute = _getScriptSourcePath(node); |
| 2042 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute
.text; | 2069 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute
.text; |
| 2043 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath
== null) { | 2070 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath
== null) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2073 } | 2100 } |
| 2074 node.scriptElement = script; | 2101 node.scriptElement = script; |
| 2075 _scripts.add(script); | 2102 _scripts.add(script); |
| 2076 } | 2103 } |
| 2077 } finally { | 2104 } finally { |
| 2078 _parentNodes.remove(node); | 2105 _parentNodes.remove(node); |
| 2079 } | 2106 } |
| 2080 return null; | 2107 return null; |
| 2081 } | 2108 } |
| 2082 | 2109 |
| 2110 @override |
| 2083 Object visitHtmlUnit(ht.HtmlUnit node) { | 2111 Object visitHtmlUnit(ht.HtmlUnit node) { |
| 2084 _parentNodes = new List<ht.XmlTagNode>(); | 2112 _parentNodes = new List<ht.XmlTagNode>(); |
| 2085 _scripts = new List<HtmlScriptElement>(); | 2113 _scripts = new List<HtmlScriptElement>(); |
| 2086 try { | 2114 try { |
| 2087 node.visitChildren(this); | 2115 node.visitChildren(this); |
| 2088 _htmlElement.scripts = new List.from(_scripts); | 2116 _htmlElement.scripts = new List.from(_scripts); |
| 2089 } finally { | 2117 } finally { |
| 2090 _scripts = null; | 2118 _scripts = null; |
| 2091 _parentNodes = null; | 2119 _parentNodes = null; |
| 2092 } | 2120 } |
| 2093 return null; | 2121 return null; |
| 2094 } | 2122 } |
| 2095 | 2123 |
| 2124 @override |
| 2096 Object visitXmlAttributeNode(ht.XmlAttributeNode node) => null; | 2125 Object visitXmlAttributeNode(ht.XmlAttributeNode node) => null; |
| 2097 | 2126 |
| 2127 @override |
| 2098 Object visitXmlTagNode(ht.XmlTagNode node) { | 2128 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 2099 if (_parentNodes.contains(node)) { | 2129 if (_parentNodes.contains(node)) { |
| 2100 return _reportCircularity(node); | 2130 return _reportCircularity(node); |
| 2101 } | 2131 } |
| 2102 _parentNodes.add(node); | 2132 _parentNodes.add(node); |
| 2103 try { | 2133 try { |
| 2104 node.visitChildren(this); | 2134 node.visitChildren(this); |
| 2105 } finally { | 2135 } finally { |
| 2106 _parentNodes.remove(node); | 2136 _parentNodes.remove(node); |
| 2107 } | 2137 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 | 2258 |
| 2229 /** | 2259 /** |
| 2230 * Create a new instance of the [BestPracticesVerifier]. | 2260 * Create a new instance of the [BestPracticesVerifier]. |
| 2231 * | 2261 * |
| 2232 * @param errorReporter the error reporter | 2262 * @param errorReporter the error reporter |
| 2233 */ | 2263 */ |
| 2234 BestPracticesVerifier(ErrorReporter errorReporter) { | 2264 BestPracticesVerifier(ErrorReporter errorReporter) { |
| 2235 this._errorReporter = errorReporter; | 2265 this._errorReporter = errorReporter; |
| 2236 } | 2266 } |
| 2237 | 2267 |
| 2268 @override |
| 2238 Object visitAsExpression(AsExpression node) { | 2269 Object visitAsExpression(AsExpression node) { |
| 2239 _checkForUnnecessaryCast(node); | 2270 _checkForUnnecessaryCast(node); |
| 2240 return super.visitAsExpression(node); | 2271 return super.visitAsExpression(node); |
| 2241 } | 2272 } |
| 2242 | 2273 |
| 2274 @override |
| 2243 Object visitAssignmentExpression(AssignmentExpression node) { | 2275 Object visitAssignmentExpression(AssignmentExpression node) { |
| 2244 sc.TokenType operatorType = node.operator.type; | 2276 sc.TokenType operatorType = node.operator.type; |
| 2245 if (operatorType != sc.TokenType.EQ) { | 2277 if (operatorType != sc.TokenType.EQ) { |
| 2246 _checkForDeprecatedMemberUse(node.bestElement, node); | 2278 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 2247 } else { | 2279 } else { |
| 2248 _checkForUseOfVoidResult(node.rightHandSide); | 2280 _checkForUseOfVoidResult(node.rightHandSide); |
| 2249 } | 2281 } |
| 2250 return super.visitAssignmentExpression(node); | 2282 return super.visitAssignmentExpression(node); |
| 2251 } | 2283 } |
| 2252 | 2284 |
| 2285 @override |
| 2253 Object visitBinaryExpression(BinaryExpression node) { | 2286 Object visitBinaryExpression(BinaryExpression node) { |
| 2254 _checkForDivisionOptimizationHint(node); | 2287 _checkForDivisionOptimizationHint(node); |
| 2255 _checkForDeprecatedMemberUse(node.bestElement, node); | 2288 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 2256 return super.visitBinaryExpression(node); | 2289 return super.visitBinaryExpression(node); |
| 2257 } | 2290 } |
| 2258 | 2291 |
| 2292 @override |
| 2259 Object visitClassDeclaration(ClassDeclaration node) { | 2293 Object visitClassDeclaration(ClassDeclaration node) { |
| 2260 ClassElement outerClass = _enclosingClass; | 2294 ClassElement outerClass = _enclosingClass; |
| 2261 try { | 2295 try { |
| 2262 _enclosingClass = node.element; | 2296 _enclosingClass = node.element; |
| 2263 // Commented out until we decide that we want this hint in the analyzer | 2297 // Commented out until we decide that we want this hint in the analyzer |
| 2264 // checkForOverrideEqualsButNotHashCode(node); | 2298 // checkForOverrideEqualsButNotHashCode(node); |
| 2265 return super.visitClassDeclaration(node); | 2299 return super.visitClassDeclaration(node); |
| 2266 } finally { | 2300 } finally { |
| 2267 _enclosingClass = outerClass; | 2301 _enclosingClass = outerClass; |
| 2268 } | 2302 } |
| 2269 } | 2303 } |
| 2270 | 2304 |
| 2305 @override |
| 2271 Object visitExportDirective(ExportDirective node) { | 2306 Object visitExportDirective(ExportDirective node) { |
| 2272 _checkForDeprecatedMemberUse(node.uriElement, node); | 2307 _checkForDeprecatedMemberUse(node.uriElement, node); |
| 2273 return super.visitExportDirective(node); | 2308 return super.visitExportDirective(node); |
| 2274 } | 2309 } |
| 2275 | 2310 |
| 2311 @override |
| 2276 Object visitFunctionDeclaration(FunctionDeclaration node) { | 2312 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 2277 _checkForMissingReturn(node.returnType, node.functionExpression.body); | 2313 _checkForMissingReturn(node.returnType, node.functionExpression.body); |
| 2278 return super.visitFunctionDeclaration(node); | 2314 return super.visitFunctionDeclaration(node); |
| 2279 } | 2315 } |
| 2280 | 2316 |
| 2317 @override |
| 2281 Object visitImportDirective(ImportDirective node) { | 2318 Object visitImportDirective(ImportDirective node) { |
| 2282 _checkForDeprecatedMemberUse(node.uriElement, node); | 2319 _checkForDeprecatedMemberUse(node.uriElement, node); |
| 2283 return super.visitImportDirective(node); | 2320 return super.visitImportDirective(node); |
| 2284 } | 2321 } |
| 2285 | 2322 |
| 2323 @override |
| 2286 Object visitIndexExpression(IndexExpression node) { | 2324 Object visitIndexExpression(IndexExpression node) { |
| 2287 _checkForDeprecatedMemberUse(node.bestElement, node); | 2325 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 2288 return super.visitIndexExpression(node); | 2326 return super.visitIndexExpression(node); |
| 2289 } | 2327 } |
| 2290 | 2328 |
| 2329 @override |
| 2291 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 2330 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 2292 _checkForDeprecatedMemberUse(node.staticElement, node); | 2331 _checkForDeprecatedMemberUse(node.staticElement, node); |
| 2293 return super.visitInstanceCreationExpression(node); | 2332 return super.visitInstanceCreationExpression(node); |
| 2294 } | 2333 } |
| 2295 | 2334 |
| 2335 @override |
| 2296 Object visitIsExpression(IsExpression node) { | 2336 Object visitIsExpression(IsExpression node) { |
| 2297 _checkAllTypeChecks(node); | 2337 _checkAllTypeChecks(node); |
| 2298 return super.visitIsExpression(node); | 2338 return super.visitIsExpression(node); |
| 2299 } | 2339 } |
| 2300 | 2340 |
| 2341 @override |
| 2301 Object visitMethodDeclaration(MethodDeclaration node) { | 2342 Object visitMethodDeclaration(MethodDeclaration node) { |
| 2302 // This was determined to not be a good hint, see: dartbug.com/16029 | 2343 // This was determined to not be a good hint, see: dartbug.com/16029 |
| 2303 //checkForOverridingPrivateMember(node); | 2344 //checkForOverridingPrivateMember(node); |
| 2304 _checkForMissingReturn(node.returnType, node.body); | 2345 _checkForMissingReturn(node.returnType, node.body); |
| 2305 return super.visitMethodDeclaration(node); | 2346 return super.visitMethodDeclaration(node); |
| 2306 } | 2347 } |
| 2307 | 2348 |
| 2349 @override |
| 2308 Object visitPostfixExpression(PostfixExpression node) { | 2350 Object visitPostfixExpression(PostfixExpression node) { |
| 2309 _checkForDeprecatedMemberUse(node.bestElement, node); | 2351 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 2310 return super.visitPostfixExpression(node); | 2352 return super.visitPostfixExpression(node); |
| 2311 } | 2353 } |
| 2312 | 2354 |
| 2355 @override |
| 2313 Object visitPrefixExpression(PrefixExpression node) { | 2356 Object visitPrefixExpression(PrefixExpression node) { |
| 2314 _checkForDeprecatedMemberUse(node.bestElement, node); | 2357 _checkForDeprecatedMemberUse(node.bestElement, node); |
| 2315 return super.visitPrefixExpression(node); | 2358 return super.visitPrefixExpression(node); |
| 2316 } | 2359 } |
| 2317 | 2360 |
| 2361 @override |
| 2318 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 2362 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 2319 _checkForDeprecatedMemberUse(node.staticElement, node); | 2363 _checkForDeprecatedMemberUse(node.staticElement, node); |
| 2320 return super.visitRedirectingConstructorInvocation(node); | 2364 return super.visitRedirectingConstructorInvocation(node); |
| 2321 } | 2365 } |
| 2322 | 2366 |
| 2367 @override |
| 2323 Object visitSimpleIdentifier(SimpleIdentifier node) { | 2368 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 2324 _checkForDeprecatedMemberUseAtIdentifier(node); | 2369 _checkForDeprecatedMemberUseAtIdentifier(node); |
| 2325 return super.visitSimpleIdentifier(node); | 2370 return super.visitSimpleIdentifier(node); |
| 2326 } | 2371 } |
| 2327 | 2372 |
| 2373 @override |
| 2328 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 2374 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 2329 _checkForDeprecatedMemberUse(node.staticElement, node); | 2375 _checkForDeprecatedMemberUse(node.staticElement, node); |
| 2330 return super.visitSuperConstructorInvocation(node); | 2376 return super.visitSuperConstructorInvocation(node); |
| 2331 } | 2377 } |
| 2332 | 2378 |
| 2379 @override |
| 2333 Object visitVariableDeclaration(VariableDeclaration node) { | 2380 Object visitVariableDeclaration(VariableDeclaration node) { |
| 2334 _checkForUseOfVoidResult(node.initializer); | 2381 _checkForUseOfVoidResult(node.initializer); |
| 2335 return super.visitVariableDeclaration(node); | 2382 return super.visitVariableDeclaration(node); |
| 2336 } | 2383 } |
| 2337 | 2384 |
| 2338 /** | 2385 /** |
| 2339 * Check for the passed is expression for the unnecessary type check hint code
s as well as null | 2386 * Check for the passed is expression for the unnecessary type check hint code
s as well as null |
| 2340 * checks expressed using an is expression. | 2387 * checks expressed using an is expression. |
| 2341 * | 2388 * |
| 2342 * @param node the is expression to check | 2389 * @param node the is expression to check |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2669 | 2716 |
| 2670 /** | 2717 /** |
| 2671 * Create a new instance of the [Dart2JSVerifier]. | 2718 * Create a new instance of the [Dart2JSVerifier]. |
| 2672 * | 2719 * |
| 2673 * @param errorReporter the error reporter | 2720 * @param errorReporter the error reporter |
| 2674 */ | 2721 */ |
| 2675 Dart2JSVerifier(ErrorReporter errorReporter) { | 2722 Dart2JSVerifier(ErrorReporter errorReporter) { |
| 2676 this._errorReporter = errorReporter; | 2723 this._errorReporter = errorReporter; |
| 2677 } | 2724 } |
| 2678 | 2725 |
| 2726 @override |
| 2679 Object visitIsExpression(IsExpression node) { | 2727 Object visitIsExpression(IsExpression node) { |
| 2680 _checkForIsDoubleHints(node); | 2728 _checkForIsDoubleHints(node); |
| 2681 return super.visitIsExpression(node); | 2729 return super.visitIsExpression(node); |
| 2682 } | 2730 } |
| 2683 | 2731 |
| 2684 /** | 2732 /** |
| 2685 * Check for instances of `x is double`, `x is int`, `x is! double` and | 2733 * Check for instances of `x is double`, `x is int`, `x is! double` and |
| 2686 * `x is! int`. | 2734 * `x is! int`. |
| 2687 * | 2735 * |
| 2688 * @param node the is expression to check | 2736 * @param node the is expression to check |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 | 2781 |
| 2734 /** | 2782 /** |
| 2735 * Create a new instance of the [DeadCodeVerifier]. | 2783 * Create a new instance of the [DeadCodeVerifier]. |
| 2736 * | 2784 * |
| 2737 * @param errorReporter the error reporter | 2785 * @param errorReporter the error reporter |
| 2738 */ | 2786 */ |
| 2739 DeadCodeVerifier(ErrorReporter errorReporter) { | 2787 DeadCodeVerifier(ErrorReporter errorReporter) { |
| 2740 this._errorReporter = errorReporter; | 2788 this._errorReporter = errorReporter; |
| 2741 } | 2789 } |
| 2742 | 2790 |
| 2791 @override |
| 2743 Object visitBinaryExpression(BinaryExpression node) { | 2792 Object visitBinaryExpression(BinaryExpression node) { |
| 2744 sc.Token operator = node.operator; | 2793 sc.Token operator = node.operator; |
| 2745 bool isAmpAmp = identical(operator.type, sc.TokenType.AMPERSAND_AMPERSAND); | 2794 bool isAmpAmp = identical(operator.type, sc.TokenType.AMPERSAND_AMPERSAND); |
| 2746 bool isBarBar = identical(operator.type, sc.TokenType.BAR_BAR); | 2795 bool isBarBar = identical(operator.type, sc.TokenType.BAR_BAR); |
| 2747 if (isAmpAmp || isBarBar) { | 2796 if (isAmpAmp || isBarBar) { |
| 2748 Expression lhsCondition = node.leftOperand; | 2797 Expression lhsCondition = node.leftOperand; |
| 2749 if (!_isDebugConstant(lhsCondition)) { | 2798 if (!_isDebugConstant(lhsCondition)) { |
| 2750 ValidResult lhsResult = _getConstantBooleanValue(lhsCondition); | 2799 ValidResult lhsResult = _getConstantBooleanValue(lhsCondition); |
| 2751 if (lhsResult != null) { | 2800 if (lhsResult != null) { |
| 2752 if (lhsResult.isTrue && isBarBar) { | 2801 if (lhsResult.isTrue && isBarBar) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2767 } | 2816 } |
| 2768 return super.visitBinaryExpression(node); | 2817 return super.visitBinaryExpression(node); |
| 2769 } | 2818 } |
| 2770 | 2819 |
| 2771 /** | 2820 /** |
| 2772 * For each [Block], this method reports and error on all statements between t
he end of the | 2821 * For each [Block], this method reports and error on all statements between t
he end of the |
| 2773 * block and the first return statement (assuming there it is not at the end o
f the block.) | 2822 * block and the first return statement (assuming there it is not at the end o
f the block.) |
| 2774 * | 2823 * |
| 2775 * @param node the block to evaluate | 2824 * @param node the block to evaluate |
| 2776 */ | 2825 */ |
| 2826 @override |
| 2777 Object visitBlock(Block node) { | 2827 Object visitBlock(Block node) { |
| 2778 NodeList<Statement> statements = node.statements; | 2828 NodeList<Statement> statements = node.statements; |
| 2779 int size = statements.length; | 2829 int size = statements.length; |
| 2780 for (int i = 0; i < size; i++) { | 2830 for (int i = 0; i < size; i++) { |
| 2781 Statement currentStatement = statements[i]; | 2831 Statement currentStatement = statements[i]; |
| 2782 _safelyVisit(currentStatement); | 2832 _safelyVisit(currentStatement); |
| 2783 if (currentStatement is ReturnStatement && i != size - 1) { | 2833 if (currentStatement is ReturnStatement && i != size - 1) { |
| 2784 Statement nextStatement = statements[i + 1]; | 2834 Statement nextStatement = statements[i + 1]; |
| 2785 Statement lastStatement = statements[size - 1]; | 2835 Statement lastStatement = statements[size - 1]; |
| 2786 int offset = nextStatement.offset; | 2836 int offset = nextStatement.offset; |
| 2787 int length = lastStatement.end - offset; | 2837 int length = lastStatement.end - offset; |
| 2788 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length,
[]); | 2838 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length,
[]); |
| 2789 return null; | 2839 return null; |
| 2790 } | 2840 } |
| 2791 } | 2841 } |
| 2792 return null; | 2842 return null; |
| 2793 } | 2843 } |
| 2794 | 2844 |
| 2845 @override |
| 2795 Object visitConditionalExpression(ConditionalExpression node) { | 2846 Object visitConditionalExpression(ConditionalExpression node) { |
| 2796 Expression conditionExpression = node.condition; | 2847 Expression conditionExpression = node.condition; |
| 2797 _safelyVisit(conditionExpression); | 2848 _safelyVisit(conditionExpression); |
| 2798 if (!_isDebugConstant(conditionExpression)) { | 2849 if (!_isDebugConstant(conditionExpression)) { |
| 2799 ValidResult result = _getConstantBooleanValue(conditionExpression); | 2850 ValidResult result = _getConstantBooleanValue(conditionExpression); |
| 2800 if (result != null) { | 2851 if (result != null) { |
| 2801 if (result.isTrue) { | 2852 if (result.isTrue) { |
| 2802 // report error on else block: true ? 1 : !2! | 2853 // report error on else block: true ? 1 : !2! |
| 2803 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.elseExpress
ion, []); | 2854 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.elseExpress
ion, []); |
| 2804 _safelyVisit(node.thenExpression); | 2855 _safelyVisit(node.thenExpression); |
| 2805 return null; | 2856 return null; |
| 2806 } else { | 2857 } else { |
| 2807 // report error on if block: false ? !1! : 2 | 2858 // report error on if block: false ? !1! : 2 |
| 2808 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.thenExpress
ion, []); | 2859 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.thenExpress
ion, []); |
| 2809 _safelyVisit(node.elseExpression); | 2860 _safelyVisit(node.elseExpression); |
| 2810 return null; | 2861 return null; |
| 2811 } | 2862 } |
| 2812 } | 2863 } |
| 2813 } | 2864 } |
| 2814 return super.visitConditionalExpression(node); | 2865 return super.visitConditionalExpression(node); |
| 2815 } | 2866 } |
| 2816 | 2867 |
| 2868 @override |
| 2817 Object visitIfStatement(IfStatement node) { | 2869 Object visitIfStatement(IfStatement node) { |
| 2818 Expression conditionExpression = node.condition; | 2870 Expression conditionExpression = node.condition; |
| 2819 _safelyVisit(conditionExpression); | 2871 _safelyVisit(conditionExpression); |
| 2820 if (!_isDebugConstant(conditionExpression)) { | 2872 if (!_isDebugConstant(conditionExpression)) { |
| 2821 ValidResult result = _getConstantBooleanValue(conditionExpression); | 2873 ValidResult result = _getConstantBooleanValue(conditionExpression); |
| 2822 if (result != null) { | 2874 if (result != null) { |
| 2823 if (result.isTrue) { | 2875 if (result.isTrue) { |
| 2824 // report error on else block: if(true) {} else {!} | 2876 // report error on else block: if(true) {} else {!} |
| 2825 Statement elseStatement = node.elseStatement; | 2877 Statement elseStatement = node.elseStatement; |
| 2826 if (elseStatement != null) { | 2878 if (elseStatement != null) { |
| 2827 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseStatement,
[]); | 2879 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseStatement,
[]); |
| 2828 _safelyVisit(node.thenStatement); | 2880 _safelyVisit(node.thenStatement); |
| 2829 return null; | 2881 return null; |
| 2830 } | 2882 } |
| 2831 } else { | 2883 } else { |
| 2832 // report error on if block: if (false) {!} else {} | 2884 // report error on if block: if (false) {!} else {} |
| 2833 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.thenStateme
nt, []); | 2885 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.thenStateme
nt, []); |
| 2834 _safelyVisit(node.elseStatement); | 2886 _safelyVisit(node.elseStatement); |
| 2835 return null; | 2887 return null; |
| 2836 } | 2888 } |
| 2837 } | 2889 } |
| 2838 } | 2890 } |
| 2839 return super.visitIfStatement(node); | 2891 return super.visitIfStatement(node); |
| 2840 } | 2892 } |
| 2841 | 2893 |
| 2894 @override |
| 2842 Object visitTryStatement(TryStatement node) { | 2895 Object visitTryStatement(TryStatement node) { |
| 2843 _safelyVisit(node.body); | 2896 _safelyVisit(node.body); |
| 2844 _safelyVisit(node.finallyBlock); | 2897 _safelyVisit(node.finallyBlock); |
| 2845 NodeList<CatchClause> catchClauses = node.catchClauses; | 2898 NodeList<CatchClause> catchClauses = node.catchClauses; |
| 2846 int numOfCatchClauses = catchClauses.length; | 2899 int numOfCatchClauses = catchClauses.length; |
| 2847 List<DartType> visitedTypes = new List<DartType>(); | 2900 List<DartType> visitedTypes = new List<DartType>(); |
| 2848 for (int i = 0; i < numOfCatchClauses; i++) { | 2901 for (int i = 0; i < numOfCatchClauses; i++) { |
| 2849 CatchClause catchClause = catchClauses[i]; | 2902 CatchClause catchClause = catchClauses[i]; |
| 2850 if (catchClause.onKeyword != null) { | 2903 if (catchClause.onKeyword != null) { |
| 2851 // on-catch clause found, verify that the exception type is not a subtyp
e of a previous | 2904 // on-catch clause found, verify that the exception type is not a subtyp
e of a previous |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 int offset = nextCatchClause.offset; | 2944 int offset = nextCatchClause.offset; |
| 2892 int length = lastCatchClause.end - offset; | 2945 int length = lastCatchClause.end - offset; |
| 2893 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLOWING
_CATCH, offset, length, []); | 2946 _errorReporter.reportErrorForOffset(HintCode.DEAD_CODE_CATCH_FOLLOWING
_CATCH, offset, length, []); |
| 2894 return null; | 2947 return null; |
| 2895 } | 2948 } |
| 2896 } | 2949 } |
| 2897 } | 2950 } |
| 2898 return null; | 2951 return null; |
| 2899 } | 2952 } |
| 2900 | 2953 |
| 2954 @override |
| 2901 Object visitWhileStatement(WhileStatement node) { | 2955 Object visitWhileStatement(WhileStatement node) { |
| 2902 Expression conditionExpression = node.condition; | 2956 Expression conditionExpression = node.condition; |
| 2903 _safelyVisit(conditionExpression); | 2957 _safelyVisit(conditionExpression); |
| 2904 if (!_isDebugConstant(conditionExpression)) { | 2958 if (!_isDebugConstant(conditionExpression)) { |
| 2905 ValidResult result = _getConstantBooleanValue(conditionExpression); | 2959 ValidResult result = _getConstantBooleanValue(conditionExpression); |
| 2906 if (result != null) { | 2960 if (result != null) { |
| 2907 if (result.isFalse) { | 2961 if (result.isFalse) { |
| 2908 // report error on if block: while (false) {!} | 2962 // report error on if block: while (false) {!} |
| 2909 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.body, []); | 2963 _errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.body, []); |
| 2910 return null; | 2964 return null; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 * to terminate by executing a `return` statement, `throw` expression, `rethrow` | 3050 * to terminate by executing a `return` statement, `throw` expression, `rethrow` |
| 2997 * expression, or simple infinite loop such as `while(true)`. | 3051 * expression, or simple infinite loop such as `while(true)`. |
| 2998 */ | 3052 */ |
| 2999 class ExitDetector extends GeneralizingAstVisitor<bool> { | 3053 class ExitDetector extends GeneralizingAstVisitor<bool> { |
| 3000 /** | 3054 /** |
| 3001 * Set to `true` when a `break` is encountered, and reset to `false` when a | 3055 * Set to `true` when a `break` is encountered, and reset to `false` when a |
| 3002 * `do`, `while`, `for` or `switch` block is entered. | 3056 * `do`, `while`, `for` or `switch` block is entered. |
| 3003 */ | 3057 */ |
| 3004 bool _enclosingBlockContainsBreak = false; | 3058 bool _enclosingBlockContainsBreak = false; |
| 3005 | 3059 |
| 3060 @override |
| 3006 bool visitArgumentList(ArgumentList node) => _visitExpressions(node.arguments)
; | 3061 bool visitArgumentList(ArgumentList node) => _visitExpressions(node.arguments)
; |
| 3007 | 3062 |
| 3063 @override |
| 3008 bool visitAsExpression(AsExpression node) => node.expression.accept(this); | 3064 bool visitAsExpression(AsExpression node) => node.expression.accept(this); |
| 3009 | 3065 |
| 3066 @override |
| 3010 bool visitAssertStatement(AssertStatement node) => node.condition.accept(this)
; | 3067 bool visitAssertStatement(AssertStatement node) => node.condition.accept(this)
; |
| 3011 | 3068 |
| 3069 @override |
| 3012 bool visitAssignmentExpression(AssignmentExpression node) => node.leftHandSide
.accept(this) || node.rightHandSide.accept(this); | 3070 bool visitAssignmentExpression(AssignmentExpression node) => node.leftHandSide
.accept(this) || node.rightHandSide.accept(this); |
| 3013 | 3071 |
| 3072 @override |
| 3014 bool visitBinaryExpression(BinaryExpression node) { | 3073 bool visitBinaryExpression(BinaryExpression node) { |
| 3015 Expression lhsExpression = node.leftOperand; | 3074 Expression lhsExpression = node.leftOperand; |
| 3016 sc.TokenType operatorType = node.operator.type; | 3075 sc.TokenType operatorType = node.operator.type; |
| 3017 // If the operator is || and the left hand side is false literal, don't cons
ider the RHS of the | 3076 // If the operator is || and the left hand side is false literal, don't cons
ider the RHS of the |
| 3018 // binary expression. | 3077 // binary expression. |
| 3019 // TODO(jwren) Do we want to take constant expressions into account, evaluat
e if(false) {} | 3078 // TODO(jwren) Do we want to take constant expressions into account, evaluat
e if(false) {} |
| 3020 // differently than if(<condition>), when <condition> evaluates to a constan
t false value? | 3079 // differently than if(<condition>), when <condition> evaluates to a constan
t false value? |
| 3021 if (identical(operatorType, sc.TokenType.BAR_BAR)) { | 3080 if (identical(operatorType, sc.TokenType.BAR_BAR)) { |
| 3022 if (lhsExpression is BooleanLiteral) { | 3081 if (lhsExpression is BooleanLiteral) { |
| 3023 BooleanLiteral booleanLiteral = lhsExpression; | 3082 BooleanLiteral booleanLiteral = lhsExpression; |
| 3024 if (!booleanLiteral.value) { | 3083 if (!booleanLiteral.value) { |
| 3025 return false; | 3084 return false; |
| 3026 } | 3085 } |
| 3027 } | 3086 } |
| 3028 } | 3087 } |
| 3029 // If the operator is && and the left hand side is true literal, don't consi
der the RHS of the | 3088 // If the operator is && and the left hand side is true literal, don't consi
der the RHS of the |
| 3030 // binary expression. | 3089 // binary expression. |
| 3031 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { | 3090 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { |
| 3032 if (lhsExpression is BooleanLiteral) { | 3091 if (lhsExpression is BooleanLiteral) { |
| 3033 BooleanLiteral booleanLiteral = lhsExpression; | 3092 BooleanLiteral booleanLiteral = lhsExpression; |
| 3034 if (booleanLiteral.value) { | 3093 if (booleanLiteral.value) { |
| 3035 return false; | 3094 return false; |
| 3036 } | 3095 } |
| 3037 } | 3096 } |
| 3038 } | 3097 } |
| 3039 return lhsExpression.accept(this) || node.rightOperand.accept(this); | 3098 return lhsExpression.accept(this) || node.rightOperand.accept(this); |
| 3040 } | 3099 } |
| 3041 | 3100 |
| 3101 @override |
| 3042 bool visitBlock(Block node) => _visitStatements(node.statements); | 3102 bool visitBlock(Block node) => _visitStatements(node.statements); |
| 3043 | 3103 |
| 3104 @override |
| 3044 bool visitBlockFunctionBody(BlockFunctionBody node) => node.block.accept(this)
; | 3105 bool visitBlockFunctionBody(BlockFunctionBody node) => node.block.accept(this)
; |
| 3045 | 3106 |
| 3107 @override |
| 3046 bool visitBreakStatement(BreakStatement node) { | 3108 bool visitBreakStatement(BreakStatement node) { |
| 3047 _enclosingBlockContainsBreak = true; | 3109 _enclosingBlockContainsBreak = true; |
| 3048 return false; | 3110 return false; |
| 3049 } | 3111 } |
| 3050 | 3112 |
| 3113 @override |
| 3051 bool visitCascadeExpression(CascadeExpression node) { | 3114 bool visitCascadeExpression(CascadeExpression node) { |
| 3052 Expression target = node.target; | 3115 Expression target = node.target; |
| 3053 if (target.accept(this)) { | 3116 if (target.accept(this)) { |
| 3054 return true; | 3117 return true; |
| 3055 } | 3118 } |
| 3056 return _visitExpressions(node.cascadeSections); | 3119 return _visitExpressions(node.cascadeSections); |
| 3057 } | 3120 } |
| 3058 | 3121 |
| 3122 @override |
| 3059 bool visitConditionalExpression(ConditionalExpression node) { | 3123 bool visitConditionalExpression(ConditionalExpression node) { |
| 3060 Expression conditionExpression = node.condition; | 3124 Expression conditionExpression = node.condition; |
| 3061 Expression thenStatement = node.thenExpression; | 3125 Expression thenStatement = node.thenExpression; |
| 3062 Expression elseStatement = node.elseExpression; | 3126 Expression elseStatement = node.elseExpression; |
| 3063 // TODO(jwren) Do we want to take constant expressions into account, evaluat
e if(false) {} | 3127 // TODO(jwren) Do we want to take constant expressions into account, evaluat
e if(false) {} |
| 3064 // differently than if(<condition>), when <condition> evaluates to a constan
t false value? | 3128 // differently than if(<condition>), when <condition> evaluates to a constan
t false value? |
| 3065 if (conditionExpression.accept(this)) { | 3129 if (conditionExpression.accept(this)) { |
| 3066 return true; | 3130 return true; |
| 3067 } | 3131 } |
| 3068 if (thenStatement == null || elseStatement == null) { | 3132 if (thenStatement == null || elseStatement == null) { |
| 3069 return false; | 3133 return false; |
| 3070 } | 3134 } |
| 3071 return thenStatement.accept(this) && elseStatement.accept(this); | 3135 return thenStatement.accept(this) && elseStatement.accept(this); |
| 3072 } | 3136 } |
| 3073 | 3137 |
| 3138 @override |
| 3074 bool visitContinueStatement(ContinueStatement node) => false; | 3139 bool visitContinueStatement(ContinueStatement node) => false; |
| 3075 | 3140 |
| 3141 @override |
| 3076 bool visitDoStatement(DoStatement node) { | 3142 bool visitDoStatement(DoStatement node) { |
| 3077 bool outerBreakValue = _enclosingBlockContainsBreak; | 3143 bool outerBreakValue = _enclosingBlockContainsBreak; |
| 3078 _enclosingBlockContainsBreak = false; | 3144 _enclosingBlockContainsBreak = false; |
| 3079 try { | 3145 try { |
| 3080 Expression conditionExpression = node.condition; | 3146 Expression conditionExpression = node.condition; |
| 3081 if (conditionExpression.accept(this)) { | 3147 if (conditionExpression.accept(this)) { |
| 3082 return true; | 3148 return true; |
| 3083 } | 3149 } |
| 3084 // TODO(jwren) Do we want to take all constant expressions into account? | 3150 // TODO(jwren) Do we want to take all constant expressions into account? |
| 3085 if (conditionExpression is BooleanLiteral) { | 3151 if (conditionExpression is BooleanLiteral) { |
| 3086 BooleanLiteral booleanLiteral = conditionExpression; | 3152 BooleanLiteral booleanLiteral = conditionExpression; |
| 3087 // If do {} while (true), and the body doesn't return or the body doesn'
t have a break, then | 3153 // If do {} while (true), and the body doesn't return or the body doesn'
t have a break, then |
| 3088 // return true. | 3154 // return true. |
| 3089 bool blockReturns = node.body.accept(this); | 3155 bool blockReturns = node.body.accept(this); |
| 3090 if (booleanLiteral.value && (blockReturns || !_enclosingBlockContainsBre
ak)) { | 3156 if (booleanLiteral.value && (blockReturns || !_enclosingBlockContainsBre
ak)) { |
| 3091 return true; | 3157 return true; |
| 3092 } | 3158 } |
| 3093 } | 3159 } |
| 3094 return false; | 3160 return false; |
| 3095 } finally { | 3161 } finally { |
| 3096 _enclosingBlockContainsBreak = outerBreakValue; | 3162 _enclosingBlockContainsBreak = outerBreakValue; |
| 3097 } | 3163 } |
| 3098 } | 3164 } |
| 3099 | 3165 |
| 3166 @override |
| 3100 bool visitEmptyStatement(EmptyStatement node) => false; | 3167 bool visitEmptyStatement(EmptyStatement node) => false; |
| 3101 | 3168 |
| 3169 @override |
| 3102 bool visitExpressionStatement(ExpressionStatement node) => node.expression.acc
ept(this); | 3170 bool visitExpressionStatement(ExpressionStatement node) => node.expression.acc
ept(this); |
| 3103 | 3171 |
| 3172 @override |
| 3104 bool visitForEachStatement(ForEachStatement node) { | 3173 bool visitForEachStatement(ForEachStatement node) { |
| 3105 bool outerBreakValue = _enclosingBlockContainsBreak; | 3174 bool outerBreakValue = _enclosingBlockContainsBreak; |
| 3106 _enclosingBlockContainsBreak = false; | 3175 _enclosingBlockContainsBreak = false; |
| 3107 try { | 3176 try { |
| 3108 return node.iterator.accept(this); | 3177 return node.iterator.accept(this); |
| 3109 } finally { | 3178 } finally { |
| 3110 _enclosingBlockContainsBreak = outerBreakValue; | 3179 _enclosingBlockContainsBreak = outerBreakValue; |
| 3111 } | 3180 } |
| 3112 } | 3181 } |
| 3113 | 3182 |
| 3183 @override |
| 3114 bool visitForStatement(ForStatement node) { | 3184 bool visitForStatement(ForStatement node) { |
| 3115 bool outerBreakValue = _enclosingBlockContainsBreak; | 3185 bool outerBreakValue = _enclosingBlockContainsBreak; |
| 3116 _enclosingBlockContainsBreak = false; | 3186 _enclosingBlockContainsBreak = false; |
| 3117 try { | 3187 try { |
| 3118 if (node.variables != null && _visitVariableDeclarations(node.variables.va
riables)) { | 3188 if (node.variables != null && _visitVariableDeclarations(node.variables.va
riables)) { |
| 3119 return true; | 3189 return true; |
| 3120 } | 3190 } |
| 3121 if (node.initialization != null && node.initialization.accept(this)) { | 3191 if (node.initialization != null && node.initialization.accept(this)) { |
| 3122 return true; | 3192 return true; |
| 3123 } | 3193 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3137 if (blockReturns || !_enclosingBlockContainsBreak) { | 3207 if (blockReturns || !_enclosingBlockContainsBreak) { |
| 3138 return true; | 3208 return true; |
| 3139 } | 3209 } |
| 3140 } | 3210 } |
| 3141 return false; | 3211 return false; |
| 3142 } finally { | 3212 } finally { |
| 3143 _enclosingBlockContainsBreak = outerBreakValue; | 3213 _enclosingBlockContainsBreak = outerBreakValue; |
| 3144 } | 3214 } |
| 3145 } | 3215 } |
| 3146 | 3216 |
| 3217 @override |
| 3147 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => f
alse; | 3218 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => f
alse; |
| 3148 | 3219 |
| 3220 @override |
| 3149 bool visitFunctionExpression(FunctionExpression node) => false; | 3221 bool visitFunctionExpression(FunctionExpression node) => false; |
| 3150 | 3222 |
| 3223 @override |
| 3151 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 3224 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 3152 if (node.function.accept(this)) { | 3225 if (node.function.accept(this)) { |
| 3153 return true; | 3226 return true; |
| 3154 } | 3227 } |
| 3155 return node.argumentList.accept(this); | 3228 return node.argumentList.accept(this); |
| 3156 } | 3229 } |
| 3157 | 3230 |
| 3231 @override |
| 3158 bool visitIdentifier(Identifier node) => false; | 3232 bool visitIdentifier(Identifier node) => false; |
| 3159 | 3233 |
| 3234 @override |
| 3160 bool visitIfStatement(IfStatement node) { | 3235 bool visitIfStatement(IfStatement node) { |
| 3161 Expression conditionExpression = node.condition; | 3236 Expression conditionExpression = node.condition; |
| 3162 Statement thenStatement = node.thenStatement; | 3237 Statement thenStatement = node.thenStatement; |
| 3163 Statement elseStatement = node.elseStatement; | 3238 Statement elseStatement = node.elseStatement; |
| 3164 if (conditionExpression.accept(this)) { | 3239 if (conditionExpression.accept(this)) { |
| 3165 return true; | 3240 return true; |
| 3166 } | 3241 } |
| 3167 // TODO(jwren) Do we want to take all constant expressions into account? | 3242 // TODO(jwren) Do we want to take all constant expressions into account? |
| 3168 if (conditionExpression is BooleanLiteral) { | 3243 if (conditionExpression is BooleanLiteral) { |
| 3169 BooleanLiteral booleanLiteral = conditionExpression; | 3244 BooleanLiteral booleanLiteral = conditionExpression; |
| 3170 if (booleanLiteral.value) { | 3245 if (booleanLiteral.value) { |
| 3171 // if(true) ... | 3246 // if(true) ... |
| 3172 return thenStatement.accept(this); | 3247 return thenStatement.accept(this); |
| 3173 } else if (elseStatement != null) { | 3248 } else if (elseStatement != null) { |
| 3174 // if (false) ... | 3249 // if (false) ... |
| 3175 return elseStatement.accept(this); | 3250 return elseStatement.accept(this); |
| 3176 } | 3251 } |
| 3177 } | 3252 } |
| 3178 if (thenStatement == null || elseStatement == null) { | 3253 if (thenStatement == null || elseStatement == null) { |
| 3179 return false; | 3254 return false; |
| 3180 } | 3255 } |
| 3181 return thenStatement.accept(this) && elseStatement.accept(this); | 3256 return thenStatement.accept(this) && elseStatement.accept(this); |
| 3182 } | 3257 } |
| 3183 | 3258 |
| 3259 @override |
| 3184 bool visitIndexExpression(IndexExpression node) { | 3260 bool visitIndexExpression(IndexExpression node) { |
| 3185 Expression target = node.realTarget; | 3261 Expression target = node.realTarget; |
| 3186 if (target != null && target.accept(this)) { | 3262 if (target != null && target.accept(this)) { |
| 3187 return true; | 3263 return true; |
| 3188 } | 3264 } |
| 3189 if (node.index.accept(this)) { | 3265 if (node.index.accept(this)) { |
| 3190 return true; | 3266 return true; |
| 3191 } | 3267 } |
| 3192 return false; | 3268 return false; |
| 3193 } | 3269 } |
| 3194 | 3270 |
| 3271 @override |
| 3195 bool visitInstanceCreationExpression(InstanceCreationExpression node) => node.
argumentList.accept(this); | 3272 bool visitInstanceCreationExpression(InstanceCreationExpression node) => node.
argumentList.accept(this); |
| 3196 | 3273 |
| 3274 @override |
| 3197 bool visitIsExpression(IsExpression node) => node.expression.accept(this); | 3275 bool visitIsExpression(IsExpression node) => node.expression.accept(this); |
| 3198 | 3276 |
| 3277 @override |
| 3199 bool visitLabel(Label node) => false; | 3278 bool visitLabel(Label node) => false; |
| 3200 | 3279 |
| 3280 @override |
| 3201 bool visitLabeledStatement(LabeledStatement node) => node.statement.accept(thi
s); | 3281 bool visitLabeledStatement(LabeledStatement node) => node.statement.accept(thi
s); |
| 3202 | 3282 |
| 3283 @override |
| 3203 bool visitLiteral(Literal node) => false; | 3284 bool visitLiteral(Literal node) => false; |
| 3204 | 3285 |
| 3286 @override |
| 3205 bool visitMethodInvocation(MethodInvocation node) { | 3287 bool visitMethodInvocation(MethodInvocation node) { |
| 3206 Expression target = node.realTarget; | 3288 Expression target = node.realTarget; |
| 3207 if (target != null && target.accept(this)) { | 3289 if (target != null && target.accept(this)) { |
| 3208 return true; | 3290 return true; |
| 3209 } | 3291 } |
| 3210 return node.argumentList.accept(this); | 3292 return node.argumentList.accept(this); |
| 3211 } | 3293 } |
| 3212 | 3294 |
| 3295 @override |
| 3213 bool visitNamedExpression(NamedExpression node) => node.expression.accept(this
); | 3296 bool visitNamedExpression(NamedExpression node) => node.expression.accept(this
); |
| 3214 | 3297 |
| 3298 @override |
| 3215 bool visitParenthesizedExpression(ParenthesizedExpression node) => node.expres
sion.accept(this); | 3299 bool visitParenthesizedExpression(ParenthesizedExpression node) => node.expres
sion.accept(this); |
| 3216 | 3300 |
| 3301 @override |
| 3217 bool visitPostfixExpression(PostfixExpression node) => false; | 3302 bool visitPostfixExpression(PostfixExpression node) => false; |
| 3218 | 3303 |
| 3304 @override |
| 3219 bool visitPrefixExpression(PrefixExpression node) => false; | 3305 bool visitPrefixExpression(PrefixExpression node) => false; |
| 3220 | 3306 |
| 3307 @override |
| 3221 bool visitPropertyAccess(PropertyAccess node) { | 3308 bool visitPropertyAccess(PropertyAccess node) { |
| 3222 Expression target = node.realTarget; | 3309 Expression target = node.realTarget; |
| 3223 if (target != null && target.accept(this)) { | 3310 if (target != null && target.accept(this)) { |
| 3224 return true; | 3311 return true; |
| 3225 } | 3312 } |
| 3226 return false; | 3313 return false; |
| 3227 } | 3314 } |
| 3228 | 3315 |
| 3316 @override |
| 3229 bool visitRethrowExpression(RethrowExpression node) => true; | 3317 bool visitRethrowExpression(RethrowExpression node) => true; |
| 3230 | 3318 |
| 3319 @override |
| 3231 bool visitReturnStatement(ReturnStatement node) => true; | 3320 bool visitReturnStatement(ReturnStatement node) => true; |
| 3232 | 3321 |
| 3322 @override |
| 3233 bool visitSuperExpression(SuperExpression node) => false; | 3323 bool visitSuperExpression(SuperExpression node) => false; |
| 3234 | 3324 |
| 3325 @override |
| 3235 bool visitSwitchCase(SwitchCase node) => _visitStatements(node.statements); | 3326 bool visitSwitchCase(SwitchCase node) => _visitStatements(node.statements); |
| 3236 | 3327 |
| 3328 @override |
| 3237 bool visitSwitchDefault(SwitchDefault node) => _visitStatements(node.statement
s); | 3329 bool visitSwitchDefault(SwitchDefault node) => _visitStatements(node.statement
s); |
| 3238 | 3330 |
| 3331 @override |
| 3239 bool visitSwitchStatement(SwitchStatement node) { | 3332 bool visitSwitchStatement(SwitchStatement node) { |
| 3240 bool outerBreakValue = _enclosingBlockContainsBreak; | 3333 bool outerBreakValue = _enclosingBlockContainsBreak; |
| 3241 _enclosingBlockContainsBreak = false; | 3334 _enclosingBlockContainsBreak = false; |
| 3242 try { | 3335 try { |
| 3243 bool hasDefault = false; | 3336 bool hasDefault = false; |
| 3244 NodeList<SwitchMember> memberList = node.members; | 3337 NodeList<SwitchMember> memberList = node.members; |
| 3245 List<SwitchMember> members = new List.from(memberList); | 3338 List<SwitchMember> members = new List.from(memberList); |
| 3246 for (int i = 0; i < members.length; i++) { | 3339 for (int i = 0; i < members.length; i++) { |
| 3247 SwitchMember switchMember = members[i]; | 3340 SwitchMember switchMember = members[i]; |
| 3248 if (switchMember is SwitchDefault) { | 3341 if (switchMember is SwitchDefault) { |
| 3249 hasDefault = true; | 3342 hasDefault = true; |
| 3250 // If this is the last member and there are no statements, return fals
e | 3343 // If this is the last member and there are no statements, return fals
e |
| 3251 if (switchMember.statements.isEmpty && i + 1 == members.length) { | 3344 if (switchMember.statements.isEmpty && i + 1 == members.length) { |
| 3252 return false; | 3345 return false; |
| 3253 } | 3346 } |
| 3254 } | 3347 } |
| 3255 // For switch members with no statements, don't visit the children, othe
rwise, return false if | 3348 // For switch members with no statements, don't visit the children, othe
rwise, return false if |
| 3256 // no return is found in the children statements | 3349 // no return is found in the children statements |
| 3257 if (!switchMember.statements.isEmpty && !switchMember.accept(this)) { | 3350 if (!switchMember.statements.isEmpty && !switchMember.accept(this)) { |
| 3258 return false; | 3351 return false; |
| 3259 } | 3352 } |
| 3260 } | 3353 } |
| 3261 return hasDefault; | 3354 return hasDefault; |
| 3262 } finally { | 3355 } finally { |
| 3263 _enclosingBlockContainsBreak = outerBreakValue; | 3356 _enclosingBlockContainsBreak = outerBreakValue; |
| 3264 } | 3357 } |
| 3265 } | 3358 } |
| 3266 | 3359 |
| 3360 @override |
| 3267 bool visitThisExpression(ThisExpression node) => false; | 3361 bool visitThisExpression(ThisExpression node) => false; |
| 3268 | 3362 |
| 3363 @override |
| 3269 bool visitThrowExpression(ThrowExpression node) => true; | 3364 bool visitThrowExpression(ThrowExpression node) => true; |
| 3270 | 3365 |
| 3366 @override |
| 3271 bool visitTryStatement(TryStatement node) { | 3367 bool visitTryStatement(TryStatement node) { |
| 3272 if (node.body.accept(this)) { | 3368 if (node.body.accept(this)) { |
| 3273 return true; | 3369 return true; |
| 3274 } | 3370 } |
| 3275 Block finallyBlock = node.finallyBlock; | 3371 Block finallyBlock = node.finallyBlock; |
| 3276 if (finallyBlock != null && finallyBlock.accept(this)) { | 3372 if (finallyBlock != null && finallyBlock.accept(this)) { |
| 3277 return true; | 3373 return true; |
| 3278 } | 3374 } |
| 3279 return false; | 3375 return false; |
| 3280 } | 3376 } |
| 3281 | 3377 |
| 3378 @override |
| 3282 bool visitTypeName(TypeName node) => false; | 3379 bool visitTypeName(TypeName node) => false; |
| 3283 | 3380 |
| 3381 @override |
| 3284 bool visitVariableDeclaration(VariableDeclaration node) { | 3382 bool visitVariableDeclaration(VariableDeclaration node) { |
| 3285 Expression initializer = node.initializer; | 3383 Expression initializer = node.initializer; |
| 3286 if (initializer != null) { | 3384 if (initializer != null) { |
| 3287 return initializer.accept(this); | 3385 return initializer.accept(this); |
| 3288 } | 3386 } |
| 3289 return false; | 3387 return false; |
| 3290 } | 3388 } |
| 3291 | 3389 |
| 3390 @override |
| 3292 bool visitVariableDeclarationList(VariableDeclarationList node) => _visitVaria
bleDeclarations(node.variables); | 3391 bool visitVariableDeclarationList(VariableDeclarationList node) => _visitVaria
bleDeclarations(node.variables); |
| 3293 | 3392 |
| 3393 @override |
| 3294 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 3394 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 3295 NodeList<VariableDeclaration> variables = node.variables.variables; | 3395 NodeList<VariableDeclaration> variables = node.variables.variables; |
| 3296 for (int i = 0; i < variables.length; i++) { | 3396 for (int i = 0; i < variables.length; i++) { |
| 3297 if (variables[i].accept(this)) { | 3397 if (variables[i].accept(this)) { |
| 3298 return true; | 3398 return true; |
| 3299 } | 3399 } |
| 3300 } | 3400 } |
| 3301 return false; | 3401 return false; |
| 3302 } | 3402 } |
| 3303 | 3403 |
| 3404 @override |
| 3304 bool visitWhileStatement(WhileStatement node) { | 3405 bool visitWhileStatement(WhileStatement node) { |
| 3305 bool outerBreakValue = _enclosingBlockContainsBreak; | 3406 bool outerBreakValue = _enclosingBlockContainsBreak; |
| 3306 _enclosingBlockContainsBreak = false; | 3407 _enclosingBlockContainsBreak = false; |
| 3307 try { | 3408 try { |
| 3308 Expression conditionExpression = node.condition; | 3409 Expression conditionExpression = node.condition; |
| 3309 if (conditionExpression.accept(this)) { | 3410 if (conditionExpression.accept(this)) { |
| 3310 return true; | 3411 return true; |
| 3311 } | 3412 } |
| 3312 // TODO(jwren) Do we want to take all constant expressions into account? | 3413 // TODO(jwren) Do we want to take all constant expressions into account? |
| 3313 if (conditionExpression is BooleanLiteral) { | 3414 if (conditionExpression is BooleanLiteral) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 if (importElement != null) { | 3636 if (importElement != null) { |
| 3536 LibraryElement libraryElement = importElement.importedLibrary; | 3637 LibraryElement libraryElement = importElement.importedLibrary; |
| 3537 if (libraryElement != null && libraryElement.isDartCore) { | 3638 if (libraryElement != null && libraryElement.isDartCore) { |
| 3538 continue; | 3639 continue; |
| 3539 } | 3640 } |
| 3540 } | 3641 } |
| 3541 errorReporter.reportErrorForNode(HintCode.UNUSED_IMPORT, unusedImport.uri,
[]); | 3642 errorReporter.reportErrorForNode(HintCode.UNUSED_IMPORT, unusedImport.uri,
[]); |
| 3542 } | 3643 } |
| 3543 } | 3644 } |
| 3544 | 3645 |
| 3646 @override |
| 3545 Object visitCompilationUnit(CompilationUnit node) { | 3647 Object visitCompilationUnit(CompilationUnit node) { |
| 3546 if (_inDefiningCompilationUnit) { | 3648 if (_inDefiningCompilationUnit) { |
| 3547 NodeList<Directive> directives = node.directives; | 3649 NodeList<Directive> directives = node.directives; |
| 3548 for (Directive directive in directives) { | 3650 for (Directive directive in directives) { |
| 3549 if (directive is ImportDirective) { | 3651 if (directive is ImportDirective) { |
| 3550 ImportDirective importDirective = directive; | 3652 ImportDirective importDirective = directive; |
| 3551 LibraryElement libraryElement = importDirective.uriElement; | 3653 LibraryElement libraryElement = importDirective.uriElement; |
| 3552 if (libraryElement != null) { | 3654 if (libraryElement != null) { |
| 3553 _unusedImports.add(importDirective); | 3655 _unusedImports.add(importDirective); |
| 3554 // | 3656 // |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 } else { | 3699 } else { |
| 3598 _duplicateImports.add(currentDirective); | 3700 _duplicateImports.add(currentDirective); |
| 3599 } | 3701 } |
| 3600 } | 3702 } |
| 3601 currentDirective = nextDirective; | 3703 currentDirective = nextDirective; |
| 3602 } | 3704 } |
| 3603 } | 3705 } |
| 3604 return super.visitCompilationUnit(node); | 3706 return super.visitCompilationUnit(node); |
| 3605 } | 3707 } |
| 3606 | 3708 |
| 3709 @override |
| 3607 Object visitExportDirective(ExportDirective node) { | 3710 Object visitExportDirective(ExportDirective node) { |
| 3608 _visitMetadata(node.metadata); | 3711 _visitMetadata(node.metadata); |
| 3609 return null; | 3712 return null; |
| 3610 } | 3713 } |
| 3611 | 3714 |
| 3715 @override |
| 3612 Object visitImportDirective(ImportDirective node) { | 3716 Object visitImportDirective(ImportDirective node) { |
| 3613 _visitMetadata(node.metadata); | 3717 _visitMetadata(node.metadata); |
| 3614 return null; | 3718 return null; |
| 3615 } | 3719 } |
| 3616 | 3720 |
| 3721 @override |
| 3617 Object visitLibraryDirective(LibraryDirective node) { | 3722 Object visitLibraryDirective(LibraryDirective node) { |
| 3618 _visitMetadata(node.metadata); | 3723 _visitMetadata(node.metadata); |
| 3619 return null; | 3724 return null; |
| 3620 } | 3725 } |
| 3621 | 3726 |
| 3727 @override |
| 3622 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 3728 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 3623 if (_unusedImports.isEmpty) { | 3729 if (_unusedImports.isEmpty) { |
| 3624 return null; | 3730 return null; |
| 3625 } | 3731 } |
| 3626 // If the prefixed identifier references some A.B, where A is a library pref
ix, then we can | 3732 // If the prefixed identifier references some A.B, where A is a library pref
ix, then we can |
| 3627 // lookup the associated ImportDirective in prefixElementMap and remove it f
rom the | 3733 // lookup the associated ImportDirective in prefixElementMap and remove it f
rom the |
| 3628 // unusedImports list. | 3734 // unusedImports list. |
| 3629 SimpleIdentifier prefixIdentifier = node.prefix; | 3735 SimpleIdentifier prefixIdentifier = node.prefix; |
| 3630 Element element = prefixIdentifier.staticElement; | 3736 Element element = prefixIdentifier.staticElement; |
| 3631 if (element is PrefixElement) { | 3737 if (element is PrefixElement) { |
| 3632 _unusedImports.remove(_prefixElementMap[element]); | 3738 _unusedImports.remove(_prefixElementMap[element]); |
| 3633 return null; | 3739 return null; |
| 3634 } | 3740 } |
| 3635 // Otherwise, pass the prefixed identifier element and name onto visitIdenti
fier. | 3741 // Otherwise, pass the prefixed identifier element and name onto visitIdenti
fier. |
| 3636 return _visitIdentifier(element, prefixIdentifier.name); | 3742 return _visitIdentifier(element, prefixIdentifier.name); |
| 3637 } | 3743 } |
| 3638 | 3744 |
| 3745 @override |
| 3639 Object visitSimpleIdentifier(SimpleIdentifier node) { | 3746 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 3640 if (_unusedImports.isEmpty) { | 3747 if (_unusedImports.isEmpty) { |
| 3641 return null; | 3748 return null; |
| 3642 } | 3749 } |
| 3643 return _visitIdentifier(node.staticElement, node.name); | 3750 return _visitIdentifier(node.staticElement, node.name); |
| 3644 } | 3751 } |
| 3645 | 3752 |
| 3646 void set inDefiningCompilationUnit(bool inDefiningCompilationUnit) { | 3753 void set inDefiningCompilationUnit(bool inDefiningCompilationUnit) { |
| 3647 this._inDefiningCompilationUnit = inDefiningCompilationUnit; | 3754 this._inDefiningCompilationUnit = inDefiningCompilationUnit; |
| 3648 } | 3755 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3782 * Initialize a newly created verifier to look for inappropriate uses of the o
verride annotation. | 3889 * Initialize a newly created verifier to look for inappropriate uses of the o
verride annotation. |
| 3783 * | 3890 * |
| 3784 * @param manager the inheritance manager used to find overridden methods | 3891 * @param manager the inheritance manager used to find overridden methods |
| 3785 * @param errorReporter the error reporter used to report errors | 3892 * @param errorReporter the error reporter used to report errors |
| 3786 */ | 3893 */ |
| 3787 OverrideVerifier(InheritanceManager manager, ErrorReporter errorReporter) { | 3894 OverrideVerifier(InheritanceManager manager, ErrorReporter errorReporter) { |
| 3788 this._manager = manager; | 3895 this._manager = manager; |
| 3789 this._errorReporter = errorReporter; | 3896 this._errorReporter = errorReporter; |
| 3790 } | 3897 } |
| 3791 | 3898 |
| 3899 @override |
| 3792 Object visitMethodDeclaration(MethodDeclaration node) { | 3900 Object visitMethodDeclaration(MethodDeclaration node) { |
| 3793 ExecutableElement element = node.element; | 3901 ExecutableElement element = node.element; |
| 3794 if (_isOverride(element)) { | 3902 if (_isOverride(element)) { |
| 3795 if (_getOverriddenMember(element) == null) { | 3903 if (_getOverriddenMember(element) == null) { |
| 3796 if (element is MethodElement) { | 3904 if (element is MethodElement) { |
| 3797 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDING_
METHOD, node.name, []); | 3905 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDING_
METHOD, node.name, []); |
| 3798 } else if (element is PropertyAccessorElement) { | 3906 } else if (element is PropertyAccessorElement) { |
| 3799 if (element.isGetter) { | 3907 if (element.isGetter) { |
| 3800 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDIN
G_GETTER, node.name, []); | 3908 _errorReporter.reportErrorForNode(HintCode.OVERRIDE_ON_NON_OVERRIDIN
G_GETTER, node.name, []); |
| 3801 } else { | 3909 } else { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3849 /** | 3957 /** |
| 3850 * The error reporter by which errors will be reported. | 3958 * The error reporter by which errors will be reported. |
| 3851 */ | 3959 */ |
| 3852 ErrorReporter _errorReporter; | 3960 ErrorReporter _errorReporter; |
| 3853 | 3961 |
| 3854 PubVerifier(AnalysisContext context, ErrorReporter errorReporter) { | 3962 PubVerifier(AnalysisContext context, ErrorReporter errorReporter) { |
| 3855 this._context = context; | 3963 this._context = context; |
| 3856 this._errorReporter = errorReporter; | 3964 this._errorReporter = errorReporter; |
| 3857 } | 3965 } |
| 3858 | 3966 |
| 3967 @override |
| 3859 Object visitImportDirective(ImportDirective directive) { | 3968 Object visitImportDirective(ImportDirective directive) { |
| 3860 return null; | 3969 return null; |
| 3861 } | 3970 } |
| 3862 | 3971 |
| 3863 /** | 3972 /** |
| 3864 * This verifies that the passed file import directive is not contained in a s
ource inside a | 3973 * This verifies that the passed file import directive is not contained in a s
ource inside a |
| 3865 * package "lib" directory hierarchy referencing a source outside that package
"lib" directory | 3974 * package "lib" directory hierarchy referencing a source outside that package
"lib" directory |
| 3866 * hierarchy. | 3975 * hierarchy. |
| 3867 * | 3976 * |
| 3868 * @param uriLiteral the import URL (not `null`) | 3977 * @param uriLiteral the import URL (not `null`) |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4117 _captureEnclosingElements(element); | 4226 _captureEnclosingElements(element); |
| 4118 _gatherElements(element); | 4227 _gatherElements(element); |
| 4119 try { | 4228 try { |
| 4120 node.accept(this); | 4229 node.accept(this); |
| 4121 } on DeclarationMatcher_DeclarationMismatchException catch (exception) { | 4230 } on DeclarationMatcher_DeclarationMismatchException catch (exception) { |
| 4122 return false; | 4231 return false; |
| 4123 } | 4232 } |
| 4124 return _unmatchedElements.isEmpty; | 4233 return _unmatchedElements.isEmpty; |
| 4125 } | 4234 } |
| 4126 | 4235 |
| 4236 @override |
| 4127 Object visitCatchClause(CatchClause node) { | 4237 Object visitCatchClause(CatchClause node) { |
| 4128 SimpleIdentifier exceptionParameter = node.exceptionParameter; | 4238 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 4129 if (exceptionParameter != null) { | 4239 if (exceptionParameter != null) { |
| 4130 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; | 4240 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; |
| 4131 LocalVariableElement exceptionElement = _findIdentifier(localVariables, ex
ceptionParameter); | 4241 LocalVariableElement exceptionElement = _findIdentifier(localVariables, ex
ceptionParameter); |
| 4132 processElement(exceptionElement); | 4242 processElement(exceptionElement); |
| 4133 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; | 4243 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 4134 if (stackTraceParameter != null) { | 4244 if (stackTraceParameter != null) { |
| 4135 LocalVariableElement stackTraceElement = _findIdentifier(localVariables,
stackTraceParameter); | 4245 LocalVariableElement stackTraceElement = _findIdentifier(localVariables,
stackTraceParameter); |
| 4136 processElement(stackTraceElement); | 4246 processElement(stackTraceElement); |
| 4137 } | 4247 } |
| 4138 } | 4248 } |
| 4139 return super.visitCatchClause(node); | 4249 return super.visitCatchClause(node); |
| 4140 } | 4250 } |
| 4141 | 4251 |
| 4252 @override |
| 4142 Object visitClassDeclaration(ClassDeclaration node) { | 4253 Object visitClassDeclaration(ClassDeclaration node) { |
| 4143 ClassElement outerClass = _enclosingClass; | 4254 ClassElement outerClass = _enclosingClass; |
| 4144 try { | 4255 try { |
| 4145 SimpleIdentifier className = node.name; | 4256 SimpleIdentifier className = node.name; |
| 4146 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); | 4257 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); |
| 4147 processElement(_enclosingClass); | 4258 processElement(_enclosingClass); |
| 4148 if (!_hasConstructor(node)) { | 4259 if (!_hasConstructor(node)) { |
| 4149 ConstructorElement constructor = _enclosingClass.unnamedConstructor; | 4260 ConstructorElement constructor = _enclosingClass.unnamedConstructor; |
| 4150 if (constructor.isSynthetic) { | 4261 if (constructor.isSynthetic) { |
| 4151 processElement(constructor); | 4262 processElement(constructor); |
| 4152 } | 4263 } |
| 4153 } | 4264 } |
| 4154 return super.visitClassDeclaration(node); | 4265 return super.visitClassDeclaration(node); |
| 4155 } finally { | 4266 } finally { |
| 4156 _enclosingClass = outerClass; | 4267 _enclosingClass = outerClass; |
| 4157 } | 4268 } |
| 4158 } | 4269 } |
| 4159 | 4270 |
| 4271 @override |
| 4160 Object visitClassTypeAlias(ClassTypeAlias node) { | 4272 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 4161 ClassElement outerClass = _enclosingClass; | 4273 ClassElement outerClass = _enclosingClass; |
| 4162 try { | 4274 try { |
| 4163 SimpleIdentifier className = node.name; | 4275 SimpleIdentifier className = node.name; |
| 4164 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); | 4276 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); |
| 4165 processElement(_enclosingClass); | 4277 processElement(_enclosingClass); |
| 4166 return super.visitClassTypeAlias(node); | 4278 return super.visitClassTypeAlias(node); |
| 4167 } finally { | 4279 } finally { |
| 4168 _enclosingClass = outerClass; | 4280 _enclosingClass = outerClass; |
| 4169 } | 4281 } |
| 4170 } | 4282 } |
| 4171 | 4283 |
| 4284 @override |
| 4172 Object visitCompilationUnit(CompilationUnit node) { | 4285 Object visitCompilationUnit(CompilationUnit node) { |
| 4173 processElement(_enclosingUnit); | 4286 processElement(_enclosingUnit); |
| 4174 return super.visitCompilationUnit(node); | 4287 return super.visitCompilationUnit(node); |
| 4175 } | 4288 } |
| 4176 | 4289 |
| 4290 @override |
| 4177 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 4291 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 4178 ExecutableElement outerExecutable = _enclosingExecutable; | 4292 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4179 try { | 4293 try { |
| 4180 SimpleIdentifier constructorName = node.name; | 4294 SimpleIdentifier constructorName = node.name; |
| 4181 if (constructorName == null) { | 4295 if (constructorName == null) { |
| 4182 _enclosingExecutable = _enclosingClass.unnamedConstructor; | 4296 _enclosingExecutable = _enclosingClass.unnamedConstructor; |
| 4183 } else { | 4297 } else { |
| 4184 _enclosingExecutable = _enclosingClass.getNamedConstructor(constructorNa
me.name); | 4298 _enclosingExecutable = _enclosingClass.getNamedConstructor(constructorNa
me.name); |
| 4185 } | 4299 } |
| 4186 processElement(_enclosingExecutable); | 4300 processElement(_enclosingExecutable); |
| 4187 return super.visitConstructorDeclaration(node); | 4301 return super.visitConstructorDeclaration(node); |
| 4188 } finally { | 4302 } finally { |
| 4189 _enclosingExecutable = outerExecutable; | 4303 _enclosingExecutable = outerExecutable; |
| 4190 } | 4304 } |
| 4191 } | 4305 } |
| 4192 | 4306 |
| 4307 @override |
| 4193 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 4308 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 4194 SimpleIdentifier variableName = node.identifier; | 4309 SimpleIdentifier variableName = node.identifier; |
| 4195 LocalVariableElement element = _findIdentifier(_enclosingExecutable.localVar
iables, variableName); | 4310 LocalVariableElement element = _findIdentifier(_enclosingExecutable.localVar
iables, variableName); |
| 4196 processElement(element); | 4311 processElement(element); |
| 4197 return super.visitDeclaredIdentifier(node); | 4312 return super.visitDeclaredIdentifier(node); |
| 4198 } | 4313 } |
| 4199 | 4314 |
| 4315 @override |
| 4200 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 4316 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 4201 SimpleIdentifier parameterName = node.parameter.identifier; | 4317 SimpleIdentifier parameterName = node.parameter.identifier; |
| 4202 ParameterElement element = _getElementForParameter(node, parameterName); | 4318 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4203 Expression defaultValue = node.defaultValue; | 4319 Expression defaultValue = node.defaultValue; |
| 4204 if (defaultValue != null) { | 4320 if (defaultValue != null) { |
| 4205 ExecutableElement outerExecutable = _enclosingExecutable; | 4321 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4206 try { | 4322 try { |
| 4207 if (element == null) { | 4323 if (element == null) { |
| 4208 } else { | 4324 } else { |
| 4209 _enclosingExecutable = element.initializer; | 4325 _enclosingExecutable = element.initializer; |
| 4210 } | 4326 } |
| 4211 defaultValue.accept(this); | 4327 defaultValue.accept(this); |
| 4212 } finally { | 4328 } finally { |
| 4213 _enclosingExecutable = outerExecutable; | 4329 _enclosingExecutable = outerExecutable; |
| 4214 } | 4330 } |
| 4215 processElement(_enclosingExecutable); | 4331 processElement(_enclosingExecutable); |
| 4216 } | 4332 } |
| 4217 ParameterElement outerParameter = _enclosingParameter; | 4333 ParameterElement outerParameter = _enclosingParameter; |
| 4218 try { | 4334 try { |
| 4219 _enclosingParameter = element; | 4335 _enclosingParameter = element; |
| 4220 processElement(_enclosingParameter); | 4336 processElement(_enclosingParameter); |
| 4221 return super.visitDefaultFormalParameter(node); | 4337 return super.visitDefaultFormalParameter(node); |
| 4222 } finally { | 4338 } finally { |
| 4223 _enclosingParameter = outerParameter; | 4339 _enclosingParameter = outerParameter; |
| 4224 } | 4340 } |
| 4225 } | 4341 } |
| 4226 | 4342 |
| 4343 @override |
| 4227 Object visitExportDirective(ExportDirective node) { | 4344 Object visitExportDirective(ExportDirective node) { |
| 4228 String uri = _getStringValue(node.uri); | 4345 String uri = _getStringValue(node.uri); |
| 4229 if (uri != null) { | 4346 if (uri != null) { |
| 4230 LibraryElement library = _enclosingUnit.library; | 4347 LibraryElement library = _enclosingUnit.library; |
| 4231 ExportElement exportElement = _findExport(library.exports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri)); | 4348 ExportElement exportElement = _findExport(library.exports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri)); |
| 4232 processElement(exportElement); | 4349 processElement(exportElement); |
| 4233 } | 4350 } |
| 4234 return super.visitExportDirective(node); | 4351 return super.visitExportDirective(node); |
| 4235 } | 4352 } |
| 4236 | 4353 |
| 4354 @override |
| 4237 Object visitFieldFormalParameter(FieldFormalParameter node) { | 4355 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 4238 if (node.parent is! DefaultFormalParameter) { | 4356 if (node.parent is! DefaultFormalParameter) { |
| 4239 SimpleIdentifier parameterName = node.identifier; | 4357 SimpleIdentifier parameterName = node.identifier; |
| 4240 ParameterElement element = _getElementForParameter(node, parameterName); | 4358 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4241 ParameterElement outerParameter = _enclosingParameter; | 4359 ParameterElement outerParameter = _enclosingParameter; |
| 4242 try { | 4360 try { |
| 4243 _enclosingParameter = element; | 4361 _enclosingParameter = element; |
| 4244 processElement(_enclosingParameter); | 4362 processElement(_enclosingParameter); |
| 4245 return super.visitFieldFormalParameter(node); | 4363 return super.visitFieldFormalParameter(node); |
| 4246 } finally { | 4364 } finally { |
| 4247 _enclosingParameter = outerParameter; | 4365 _enclosingParameter = outerParameter; |
| 4248 } | 4366 } |
| 4249 } else { | 4367 } else { |
| 4250 return super.visitFieldFormalParameter(node); | 4368 return super.visitFieldFormalParameter(node); |
| 4251 } | 4369 } |
| 4252 } | 4370 } |
| 4253 | 4371 |
| 4372 @override |
| 4254 Object visitFunctionDeclaration(FunctionDeclaration node) { | 4373 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 4255 ExecutableElement outerExecutable = _enclosingExecutable; | 4374 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4256 try { | 4375 try { |
| 4257 SimpleIdentifier functionName = node.name; | 4376 SimpleIdentifier functionName = node.name; |
| 4258 sc.Token property = node.propertyKeyword; | 4377 sc.Token property = node.propertyKeyword; |
| 4259 if (property == null) { | 4378 if (property == null) { |
| 4260 if (_enclosingExecutable != null) { | 4379 if (_enclosingExecutable != null) { |
| 4261 _enclosingExecutable = _findIdentifier(_enclosingExecutable.functions,
functionName); | 4380 _enclosingExecutable = _findIdentifier(_enclosingExecutable.functions,
functionName); |
| 4262 } else { | 4381 } else { |
| 4263 _enclosingExecutable = _findIdentifier(_enclosingUnit.functions, funct
ionName); | 4382 _enclosingExecutable = _findIdentifier(_enclosingUnit.functions, funct
ionName); |
| 4264 } | 4383 } |
| 4265 } else { | 4384 } else { |
| 4266 PropertyAccessorElement accessor = _findIdentifier(_enclosingUnit.access
ors, functionName); | 4385 PropertyAccessorElement accessor = _findIdentifier(_enclosingUnit.access
ors, functionName); |
| 4267 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { | 4386 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { |
| 4268 accessor = accessor.variable.setter; | 4387 accessor = accessor.variable.setter; |
| 4269 } | 4388 } |
| 4270 _enclosingExecutable = accessor; | 4389 _enclosingExecutable = accessor; |
| 4271 } | 4390 } |
| 4272 processElement(_enclosingExecutable); | 4391 processElement(_enclosingExecutable); |
| 4273 return super.visitFunctionDeclaration(node); | 4392 return super.visitFunctionDeclaration(node); |
| 4274 } finally { | 4393 } finally { |
| 4275 _enclosingExecutable = outerExecutable; | 4394 _enclosingExecutable = outerExecutable; |
| 4276 } | 4395 } |
| 4277 } | 4396 } |
| 4278 | 4397 |
| 4398 @override |
| 4279 Object visitFunctionExpression(FunctionExpression node) { | 4399 Object visitFunctionExpression(FunctionExpression node) { |
| 4280 if (node.parent is! FunctionDeclaration) { | 4400 if (node.parent is! FunctionDeclaration) { |
| 4281 FunctionElement element = _findAtOffset(_enclosingExecutable.functions, no
de.beginToken.offset); | 4401 FunctionElement element = _findAtOffset(_enclosingExecutable.functions, no
de.beginToken.offset); |
| 4282 processElement(element); | 4402 processElement(element); |
| 4283 } | 4403 } |
| 4284 ExecutableElement outerExecutable = _enclosingExecutable; | 4404 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4285 try { | 4405 try { |
| 4286 _enclosingExecutable = node.element; | 4406 _enclosingExecutable = node.element; |
| 4287 processElement(_enclosingExecutable); | 4407 processElement(_enclosingExecutable); |
| 4288 return super.visitFunctionExpression(node); | 4408 return super.visitFunctionExpression(node); |
| 4289 } finally { | 4409 } finally { |
| 4290 _enclosingExecutable = outerExecutable; | 4410 _enclosingExecutable = outerExecutable; |
| 4291 } | 4411 } |
| 4292 } | 4412 } |
| 4293 | 4413 |
| 4414 @override |
| 4294 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 4415 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 4295 FunctionTypeAliasElement outerAlias = _enclosingAlias; | 4416 FunctionTypeAliasElement outerAlias = _enclosingAlias; |
| 4296 try { | 4417 try { |
| 4297 SimpleIdentifier aliasName = node.name; | 4418 SimpleIdentifier aliasName = node.name; |
| 4298 _enclosingAlias = _findIdentifier(_enclosingUnit.functionTypeAliases, alia
sName); | 4419 _enclosingAlias = _findIdentifier(_enclosingUnit.functionTypeAliases, alia
sName); |
| 4299 processElement(_enclosingAlias); | 4420 processElement(_enclosingAlias); |
| 4300 return super.visitFunctionTypeAlias(node); | 4421 return super.visitFunctionTypeAlias(node); |
| 4301 } finally { | 4422 } finally { |
| 4302 _enclosingAlias = outerAlias; | 4423 _enclosingAlias = outerAlias; |
| 4303 } | 4424 } |
| 4304 } | 4425 } |
| 4305 | 4426 |
| 4427 @override |
| 4306 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 4428 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 4307 if (node.parent is! DefaultFormalParameter) { | 4429 if (node.parent is! DefaultFormalParameter) { |
| 4308 SimpleIdentifier parameterName = node.identifier; | 4430 SimpleIdentifier parameterName = node.identifier; |
| 4309 ParameterElement element = _getElementForParameter(node, parameterName); | 4431 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4310 ParameterElement outerParameter = _enclosingParameter; | 4432 ParameterElement outerParameter = _enclosingParameter; |
| 4311 try { | 4433 try { |
| 4312 _enclosingParameter = element; | 4434 _enclosingParameter = element; |
| 4313 processElement(_enclosingParameter); | 4435 processElement(_enclosingParameter); |
| 4314 return super.visitFunctionTypedFormalParameter(node); | 4436 return super.visitFunctionTypedFormalParameter(node); |
| 4315 } finally { | 4437 } finally { |
| 4316 _enclosingParameter = outerParameter; | 4438 _enclosingParameter = outerParameter; |
| 4317 } | 4439 } |
| 4318 } else { | 4440 } else { |
| 4319 return super.visitFunctionTypedFormalParameter(node); | 4441 return super.visitFunctionTypedFormalParameter(node); |
| 4320 } | 4442 } |
| 4321 } | 4443 } |
| 4322 | 4444 |
| 4445 @override |
| 4323 Object visitImportDirective(ImportDirective node) { | 4446 Object visitImportDirective(ImportDirective node) { |
| 4324 String uri = _getStringValue(node.uri); | 4447 String uri = _getStringValue(node.uri); |
| 4325 if (uri != null) { | 4448 if (uri != null) { |
| 4326 LibraryElement library = _enclosingUnit.library; | 4449 LibraryElement library = _enclosingUnit.library; |
| 4327 ImportElement importElement = _findImport(library.imports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri), node.prefix); | 4450 ImportElement importElement = _findImport(library.imports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri), node.prefix); |
| 4328 processElement(importElement); | 4451 processElement(importElement); |
| 4329 } | 4452 } |
| 4330 return super.visitImportDirective(node); | 4453 return super.visitImportDirective(node); |
| 4331 } | 4454 } |
| 4332 | 4455 |
| 4456 @override |
| 4333 Object visitLabeledStatement(LabeledStatement node) { | 4457 Object visitLabeledStatement(LabeledStatement node) { |
| 4334 for (Label label in node.labels) { | 4458 for (Label label in node.labels) { |
| 4335 SimpleIdentifier labelName = label.label; | 4459 SimpleIdentifier labelName = label.label; |
| 4336 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); | 4460 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); |
| 4337 processElement(element); | 4461 processElement(element); |
| 4338 } | 4462 } |
| 4339 return super.visitLabeledStatement(node); | 4463 return super.visitLabeledStatement(node); |
| 4340 } | 4464 } |
| 4341 | 4465 |
| 4466 @override |
| 4342 Object visitMethodDeclaration(MethodDeclaration node) { | 4467 Object visitMethodDeclaration(MethodDeclaration node) { |
| 4343 ExecutableElement outerExecutable = _enclosingExecutable; | 4468 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4344 try { | 4469 try { |
| 4345 sc.Token property = node.propertyKeyword; | 4470 sc.Token property = node.propertyKeyword; |
| 4346 SimpleIdentifier methodName = node.name; | 4471 SimpleIdentifier methodName = node.name; |
| 4347 String nameOfMethod = methodName.name; | 4472 String nameOfMethod = methodName.name; |
| 4348 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { | 4473 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { |
| 4349 nameOfMethod = "unary-"; | 4474 nameOfMethod = "unary-"; |
| 4350 } | 4475 } |
| 4351 if (property == null) { | 4476 if (property == null) { |
| 4352 _enclosingExecutable = _findWithNameAndOffset(_enclosingClass.methods, n
ameOfMethod, methodName.offset); | 4477 _enclosingExecutable = _findWithNameAndOffset(_enclosingClass.methods, n
ameOfMethod, methodName.offset); |
| 4353 methodName.staticElement = _enclosingExecutable; | 4478 methodName.staticElement = _enclosingExecutable; |
| 4354 } else { | 4479 } else { |
| 4355 PropertyAccessorElement accessor = _findIdentifier(_enclosingClass.acces
sors, methodName); | 4480 PropertyAccessorElement accessor = _findIdentifier(_enclosingClass.acces
sors, methodName); |
| 4356 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { | 4481 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { |
| 4357 accessor = accessor.variable.setter; | 4482 accessor = accessor.variable.setter; |
| 4358 methodName.staticElement = accessor; | 4483 methodName.staticElement = accessor; |
| 4359 } | 4484 } |
| 4360 _enclosingExecutable = accessor; | 4485 _enclosingExecutable = accessor; |
| 4361 } | 4486 } |
| 4362 processElement(_enclosingExecutable); | 4487 processElement(_enclosingExecutable); |
| 4363 return super.visitMethodDeclaration(node); | 4488 return super.visitMethodDeclaration(node); |
| 4364 } finally { | 4489 } finally { |
| 4365 _enclosingExecutable = outerExecutable; | 4490 _enclosingExecutable = outerExecutable; |
| 4366 } | 4491 } |
| 4367 } | 4492 } |
| 4368 | 4493 |
| 4494 @override |
| 4369 Object visitPartDirective(PartDirective node) { | 4495 Object visitPartDirective(PartDirective node) { |
| 4370 String uri = _getStringValue(node.uri); | 4496 String uri = _getStringValue(node.uri); |
| 4371 if (uri != null) { | 4497 if (uri != null) { |
| 4372 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri); | 4498 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri); |
| 4373 CompilationUnitElement element = _findPart(_enclosingUnit.library.parts, p
artSource); | 4499 CompilationUnitElement element = _findPart(_enclosingUnit.library.parts, p
artSource); |
| 4374 processElement(element); | 4500 processElement(element); |
| 4375 } | 4501 } |
| 4376 return super.visitPartDirective(node); | 4502 return super.visitPartDirective(node); |
| 4377 } | 4503 } |
| 4378 | 4504 |
| 4505 @override |
| 4379 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 4506 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 4380 if (node.parent is! DefaultFormalParameter) { | 4507 if (node.parent is! DefaultFormalParameter) { |
| 4381 SimpleIdentifier parameterName = node.identifier; | 4508 SimpleIdentifier parameterName = node.identifier; |
| 4382 ParameterElement element = _getElementForParameter(node, parameterName); | 4509 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4383 ParameterElement outerParameter = _enclosingParameter; | 4510 ParameterElement outerParameter = _enclosingParameter; |
| 4384 try { | 4511 try { |
| 4385 _enclosingParameter = element; | 4512 _enclosingParameter = element; |
| 4386 processElement(_enclosingParameter); | 4513 processElement(_enclosingParameter); |
| 4387 return super.visitSimpleFormalParameter(node); | 4514 return super.visitSimpleFormalParameter(node); |
| 4388 } finally { | 4515 } finally { |
| 4389 _enclosingParameter = outerParameter; | 4516 _enclosingParameter = outerParameter; |
| 4390 } | 4517 } |
| 4391 } else { | 4518 } else { |
| 4392 } | 4519 } |
| 4393 return super.visitSimpleFormalParameter(node); | 4520 return super.visitSimpleFormalParameter(node); |
| 4394 } | 4521 } |
| 4395 | 4522 |
| 4523 @override |
| 4396 Object visitSwitchCase(SwitchCase node) { | 4524 Object visitSwitchCase(SwitchCase node) { |
| 4397 for (Label label in node.labels) { | 4525 for (Label label in node.labels) { |
| 4398 SimpleIdentifier labelName = label.label; | 4526 SimpleIdentifier labelName = label.label; |
| 4399 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); | 4527 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); |
| 4400 processElement(element); | 4528 processElement(element); |
| 4401 } | 4529 } |
| 4402 return super.visitSwitchCase(node); | 4530 return super.visitSwitchCase(node); |
| 4403 } | 4531 } |
| 4404 | 4532 |
| 4533 @override |
| 4405 Object visitSwitchDefault(SwitchDefault node) { | 4534 Object visitSwitchDefault(SwitchDefault node) { |
| 4406 for (Label label in node.labels) { | 4535 for (Label label in node.labels) { |
| 4407 SimpleIdentifier labelName = label.label; | 4536 SimpleIdentifier labelName = label.label; |
| 4408 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); | 4537 LabelElement element = _findIdentifier(_enclosingExecutable.labels, labelN
ame); |
| 4409 processElement(element); | 4538 processElement(element); |
| 4410 } | 4539 } |
| 4411 return super.visitSwitchDefault(node); | 4540 return super.visitSwitchDefault(node); |
| 4412 } | 4541 } |
| 4413 | 4542 |
| 4543 @override |
| 4414 Object visitTypeParameter(TypeParameter node) { | 4544 Object visitTypeParameter(TypeParameter node) { |
| 4415 SimpleIdentifier parameterName = node.name; | 4545 SimpleIdentifier parameterName = node.name; |
| 4416 TypeParameterElement element = null; | 4546 TypeParameterElement element = null; |
| 4417 if (_enclosingClass != null) { | 4547 if (_enclosingClass != null) { |
| 4418 element = _findIdentifier(_enclosingClass.typeParameters, parameterName); | 4548 element = _findIdentifier(_enclosingClass.typeParameters, parameterName); |
| 4419 } else if (_enclosingAlias != null) { | 4549 } else if (_enclosingAlias != null) { |
| 4420 element = _findIdentifier(_enclosingAlias.typeParameters, parameterName); | 4550 element = _findIdentifier(_enclosingAlias.typeParameters, parameterName); |
| 4421 } | 4551 } |
| 4422 processElement(element); | 4552 processElement(element); |
| 4423 return super.visitTypeParameter(node); | 4553 return super.visitTypeParameter(node); |
| 4424 } | 4554 } |
| 4425 | 4555 |
| 4556 @override |
| 4426 Object visitVariableDeclaration(VariableDeclaration node) { | 4557 Object visitVariableDeclaration(VariableDeclaration node) { |
| 4427 VariableElement element = null; | 4558 VariableElement element = null; |
| 4428 SimpleIdentifier variableName = node.name; | 4559 SimpleIdentifier variableName = node.name; |
| 4429 if (_enclosingExecutable != null) { | 4560 if (_enclosingExecutable != null) { |
| 4430 element = _findIdentifier(_enclosingExecutable.localVariables, variableNam
e); | 4561 element = _findIdentifier(_enclosingExecutable.localVariables, variableNam
e); |
| 4431 } | 4562 } |
| 4432 if (element == null && _enclosingClass != null) { | 4563 if (element == null && _enclosingClass != null) { |
| 4433 element = _findIdentifier(_enclosingClass.fields, variableName); | 4564 element = _findIdentifier(_enclosingClass.fields, variableName); |
| 4434 } | 4565 } |
| 4435 if (element == null && _enclosingUnit != null) { | 4566 if (element == null && _enclosingUnit != null) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4657 * element model. | 4788 * element model. |
| 4658 */ | 4789 */ |
| 4659 class DeclarationMatcher_DeclarationMismatchException extends RuntimeException { | 4790 class DeclarationMatcher_DeclarationMismatchException extends RuntimeException { |
| 4660 } | 4791 } |
| 4661 | 4792 |
| 4662 class GeneralizingElementVisitor_DeclarationMatcher_gatherElements extends Gener
alizingElementVisitor<Object> { | 4793 class GeneralizingElementVisitor_DeclarationMatcher_gatherElements extends Gener
alizingElementVisitor<Object> { |
| 4663 final DeclarationMatcher DeclarationMatcher_this; | 4794 final DeclarationMatcher DeclarationMatcher_this; |
| 4664 | 4795 |
| 4665 GeneralizingElementVisitor_DeclarationMatcher_gatherElements(this.DeclarationM
atcher_this) : super(); | 4796 GeneralizingElementVisitor_DeclarationMatcher_gatherElements(this.DeclarationM
atcher_this) : super(); |
| 4666 | 4797 |
| 4798 @override |
| 4667 Object visitElement(Element element) { | 4799 Object visitElement(Element element) { |
| 4668 DeclarationMatcher_this._allElements.add(element); | 4800 DeclarationMatcher_this._allElements.add(element); |
| 4669 DeclarationMatcher_this._unmatchedElements.add(element); | 4801 DeclarationMatcher_this._unmatchedElements.add(element); |
| 4670 return super.visitElement(element); | 4802 return super.visitElement(element); |
| 4671 } | 4803 } |
| 4672 } | 4804 } |
| 4673 | 4805 |
| 4674 /** | 4806 /** |
| 4675 * Instances of the class `DeclarationResolver` are used to resolve declarations
in an AST | 4807 * Instances of the class `DeclarationResolver` are used to resolve declarations
in an AST |
| 4676 * structure to already built elements. | 4808 * structure to already built elements. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4711 * | 4843 * |
| 4712 * @param unit the compilation unit to be resolved | 4844 * @param unit the compilation unit to be resolved |
| 4713 * @param element the root of the element model used to resolve the AST nodes | 4845 * @param element the root of the element model used to resolve the AST nodes |
| 4714 */ | 4846 */ |
| 4715 void resolve(CompilationUnit unit, CompilationUnitElement element) { | 4847 void resolve(CompilationUnit unit, CompilationUnitElement element) { |
| 4716 _enclosingUnit = element; | 4848 _enclosingUnit = element; |
| 4717 unit.element = element; | 4849 unit.element = element; |
| 4718 unit.accept(this); | 4850 unit.accept(this); |
| 4719 } | 4851 } |
| 4720 | 4852 |
| 4853 @override |
| 4721 Object visitCatchClause(CatchClause node) { | 4854 Object visitCatchClause(CatchClause node) { |
| 4722 SimpleIdentifier exceptionParameter = node.exceptionParameter; | 4855 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 4723 if (exceptionParameter != null) { | 4856 if (exceptionParameter != null) { |
| 4724 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; | 4857 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; |
| 4725 _findIdentifier(localVariables, exceptionParameter); | 4858 _findIdentifier(localVariables, exceptionParameter); |
| 4726 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; | 4859 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 4727 if (stackTraceParameter != null) { | 4860 if (stackTraceParameter != null) { |
| 4728 _findIdentifier(localVariables, stackTraceParameter); | 4861 _findIdentifier(localVariables, stackTraceParameter); |
| 4729 } | 4862 } |
| 4730 } | 4863 } |
| 4731 return super.visitCatchClause(node); | 4864 return super.visitCatchClause(node); |
| 4732 } | 4865 } |
| 4733 | 4866 |
| 4867 @override |
| 4734 Object visitClassDeclaration(ClassDeclaration node) { | 4868 Object visitClassDeclaration(ClassDeclaration node) { |
| 4735 ClassElement outerClass = _enclosingClass; | 4869 ClassElement outerClass = _enclosingClass; |
| 4736 try { | 4870 try { |
| 4737 SimpleIdentifier className = node.name; | 4871 SimpleIdentifier className = node.name; |
| 4738 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); | 4872 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); |
| 4739 return super.visitClassDeclaration(node); | 4873 return super.visitClassDeclaration(node); |
| 4740 } finally { | 4874 } finally { |
| 4741 _enclosingClass = outerClass; | 4875 _enclosingClass = outerClass; |
| 4742 } | 4876 } |
| 4743 } | 4877 } |
| 4744 | 4878 |
| 4879 @override |
| 4745 Object visitClassTypeAlias(ClassTypeAlias node) { | 4880 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 4746 ClassElement outerClass = _enclosingClass; | 4881 ClassElement outerClass = _enclosingClass; |
| 4747 try { | 4882 try { |
| 4748 SimpleIdentifier className = node.name; | 4883 SimpleIdentifier className = node.name; |
| 4749 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); | 4884 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); |
| 4750 return super.visitClassTypeAlias(node); | 4885 return super.visitClassTypeAlias(node); |
| 4751 } finally { | 4886 } finally { |
| 4752 _enclosingClass = outerClass; | 4887 _enclosingClass = outerClass; |
| 4753 } | 4888 } |
| 4754 } | 4889 } |
| 4755 | 4890 |
| 4891 @override |
| 4756 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 4892 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 4757 ExecutableElement outerExecutable = _enclosingExecutable; | 4893 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4758 try { | 4894 try { |
| 4759 SimpleIdentifier constructorName = node.name; | 4895 SimpleIdentifier constructorName = node.name; |
| 4760 if (constructorName == null) { | 4896 if (constructorName == null) { |
| 4761 _enclosingExecutable = _enclosingClass.unnamedConstructor; | 4897 _enclosingExecutable = _enclosingClass.unnamedConstructor; |
| 4762 } else { | 4898 } else { |
| 4763 _enclosingExecutable = _enclosingClass.getNamedConstructor(constructorNa
me.name); | 4899 _enclosingExecutable = _enclosingClass.getNamedConstructor(constructorNa
me.name); |
| 4764 constructorName.staticElement = _enclosingExecutable; | 4900 constructorName.staticElement = _enclosingExecutable; |
| 4765 } | 4901 } |
| 4766 node.element = _enclosingExecutable as ConstructorElement; | 4902 node.element = _enclosingExecutable as ConstructorElement; |
| 4767 return super.visitConstructorDeclaration(node); | 4903 return super.visitConstructorDeclaration(node); |
| 4768 } finally { | 4904 } finally { |
| 4769 _enclosingExecutable = outerExecutable; | 4905 _enclosingExecutable = outerExecutable; |
| 4770 } | 4906 } |
| 4771 } | 4907 } |
| 4772 | 4908 |
| 4909 @override |
| 4773 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 4910 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 4774 SimpleIdentifier variableName = node.identifier; | 4911 SimpleIdentifier variableName = node.identifier; |
| 4775 _findIdentifier(_enclosingExecutable.localVariables, variableName); | 4912 _findIdentifier(_enclosingExecutable.localVariables, variableName); |
| 4776 return super.visitDeclaredIdentifier(node); | 4913 return super.visitDeclaredIdentifier(node); |
| 4777 } | 4914 } |
| 4778 | 4915 |
| 4916 @override |
| 4779 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 4917 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 4780 SimpleIdentifier parameterName = node.parameter.identifier; | 4918 SimpleIdentifier parameterName = node.parameter.identifier; |
| 4781 ParameterElement element = _getElementForParameter(node, parameterName); | 4919 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4782 Expression defaultValue = node.defaultValue; | 4920 Expression defaultValue = node.defaultValue; |
| 4783 if (defaultValue != null) { | 4921 if (defaultValue != null) { |
| 4784 ExecutableElement outerExecutable = _enclosingExecutable; | 4922 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4785 try { | 4923 try { |
| 4786 if (element == null) { | 4924 if (element == null) { |
| 4787 } else { | 4925 } else { |
| 4788 _enclosingExecutable = element.initializer; | 4926 _enclosingExecutable = element.initializer; |
| 4789 } | 4927 } |
| 4790 defaultValue.accept(this); | 4928 defaultValue.accept(this); |
| 4791 } finally { | 4929 } finally { |
| 4792 _enclosingExecutable = outerExecutable; | 4930 _enclosingExecutable = outerExecutable; |
| 4793 } | 4931 } |
| 4794 } | 4932 } |
| 4795 ParameterElement outerParameter = _enclosingParameter; | 4933 ParameterElement outerParameter = _enclosingParameter; |
| 4796 try { | 4934 try { |
| 4797 _enclosingParameter = element; | 4935 _enclosingParameter = element; |
| 4798 return super.visitDefaultFormalParameter(node); | 4936 return super.visitDefaultFormalParameter(node); |
| 4799 } finally { | 4937 } finally { |
| 4800 _enclosingParameter = outerParameter; | 4938 _enclosingParameter = outerParameter; |
| 4801 } | 4939 } |
| 4802 } | 4940 } |
| 4803 | 4941 |
| 4942 @override |
| 4804 Object visitExportDirective(ExportDirective node) { | 4943 Object visitExportDirective(ExportDirective node) { |
| 4805 String uri = _getStringValue(node.uri); | 4944 String uri = _getStringValue(node.uri); |
| 4806 if (uri != null) { | 4945 if (uri != null) { |
| 4807 LibraryElement library = _enclosingUnit.library; | 4946 LibraryElement library = _enclosingUnit.library; |
| 4808 ExportElement exportElement = _findExport(library.exports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri)); | 4947 ExportElement exportElement = _findExport(library.exports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri)); |
| 4809 node.element = exportElement; | 4948 node.element = exportElement; |
| 4810 } | 4949 } |
| 4811 return super.visitExportDirective(node); | 4950 return super.visitExportDirective(node); |
| 4812 } | 4951 } |
| 4813 | 4952 |
| 4953 @override |
| 4814 Object visitFieldFormalParameter(FieldFormalParameter node) { | 4954 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 4815 if (node.parent is! DefaultFormalParameter) { | 4955 if (node.parent is! DefaultFormalParameter) { |
| 4816 SimpleIdentifier parameterName = node.identifier; | 4956 SimpleIdentifier parameterName = node.identifier; |
| 4817 ParameterElement element = _getElementForParameter(node, parameterName); | 4957 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4818 ParameterElement outerParameter = _enclosingParameter; | 4958 ParameterElement outerParameter = _enclosingParameter; |
| 4819 try { | 4959 try { |
| 4820 _enclosingParameter = element; | 4960 _enclosingParameter = element; |
| 4821 return super.visitFieldFormalParameter(node); | 4961 return super.visitFieldFormalParameter(node); |
| 4822 } finally { | 4962 } finally { |
| 4823 _enclosingParameter = outerParameter; | 4963 _enclosingParameter = outerParameter; |
| 4824 } | 4964 } |
| 4825 } else { | 4965 } else { |
| 4826 return super.visitFieldFormalParameter(node); | 4966 return super.visitFieldFormalParameter(node); |
| 4827 } | 4967 } |
| 4828 } | 4968 } |
| 4829 | 4969 |
| 4970 @override |
| 4830 Object visitFunctionDeclaration(FunctionDeclaration node) { | 4971 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 4831 ExecutableElement outerExecutable = _enclosingExecutable; | 4972 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4832 try { | 4973 try { |
| 4833 SimpleIdentifier functionName = node.name; | 4974 SimpleIdentifier functionName = node.name; |
| 4834 sc.Token property = node.propertyKeyword; | 4975 sc.Token property = node.propertyKeyword; |
| 4835 if (property == null) { | 4976 if (property == null) { |
| 4836 if (_enclosingExecutable != null) { | 4977 if (_enclosingExecutable != null) { |
| 4837 _enclosingExecutable = _findIdentifier(_enclosingExecutable.functions,
functionName); | 4978 _enclosingExecutable = _findIdentifier(_enclosingExecutable.functions,
functionName); |
| 4838 } else { | 4979 } else { |
| 4839 _enclosingExecutable = _findIdentifier(_enclosingUnit.functions, funct
ionName); | 4980 _enclosingExecutable = _findIdentifier(_enclosingUnit.functions, funct
ionName); |
| 4840 } | 4981 } |
| 4841 } else { | 4982 } else { |
| 4842 PropertyAccessorElement accessor = _findIdentifier(_enclosingUnit.access
ors, functionName); | 4983 PropertyAccessorElement accessor = _findIdentifier(_enclosingUnit.access
ors, functionName); |
| 4843 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { | 4984 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { |
| 4844 accessor = accessor.variable.setter; | 4985 accessor = accessor.variable.setter; |
| 4845 functionName.staticElement = accessor; | 4986 functionName.staticElement = accessor; |
| 4846 } | 4987 } |
| 4847 _enclosingExecutable = accessor; | 4988 _enclosingExecutable = accessor; |
| 4848 } | 4989 } |
| 4849 node.functionExpression.element = _enclosingExecutable; | 4990 node.functionExpression.element = _enclosingExecutable; |
| 4850 return super.visitFunctionDeclaration(node); | 4991 return super.visitFunctionDeclaration(node); |
| 4851 } finally { | 4992 } finally { |
| 4852 _enclosingExecutable = outerExecutable; | 4993 _enclosingExecutable = outerExecutable; |
| 4853 } | 4994 } |
| 4854 } | 4995 } |
| 4855 | 4996 |
| 4997 @override |
| 4856 Object visitFunctionExpression(FunctionExpression node) { | 4998 Object visitFunctionExpression(FunctionExpression node) { |
| 4857 if (node.parent is! FunctionDeclaration) { | 4999 if (node.parent is! FunctionDeclaration) { |
| 4858 FunctionElement element = _findAtOffset(_enclosingExecutable.functions, no
de.beginToken.offset); | 5000 FunctionElement element = _findAtOffset(_enclosingExecutable.functions, no
de.beginToken.offset); |
| 4859 node.element = element; | 5001 node.element = element; |
| 4860 } | 5002 } |
| 4861 ExecutableElement outerExecutable = _enclosingExecutable; | 5003 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4862 try { | 5004 try { |
| 4863 _enclosingExecutable = node.element; | 5005 _enclosingExecutable = node.element; |
| 4864 return super.visitFunctionExpression(node); | 5006 return super.visitFunctionExpression(node); |
| 4865 } finally { | 5007 } finally { |
| 4866 _enclosingExecutable = outerExecutable; | 5008 _enclosingExecutable = outerExecutable; |
| 4867 } | 5009 } |
| 4868 } | 5010 } |
| 4869 | 5011 |
| 5012 @override |
| 4870 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 5013 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 4871 FunctionTypeAliasElement outerAlias = _enclosingAlias; | 5014 FunctionTypeAliasElement outerAlias = _enclosingAlias; |
| 4872 try { | 5015 try { |
| 4873 SimpleIdentifier aliasName = node.name; | 5016 SimpleIdentifier aliasName = node.name; |
| 4874 _enclosingAlias = _findIdentifier(_enclosingUnit.functionTypeAliases, alia
sName); | 5017 _enclosingAlias = _findIdentifier(_enclosingUnit.functionTypeAliases, alia
sName); |
| 4875 return super.visitFunctionTypeAlias(node); | 5018 return super.visitFunctionTypeAlias(node); |
| 4876 } finally { | 5019 } finally { |
| 4877 _enclosingAlias = outerAlias; | 5020 _enclosingAlias = outerAlias; |
| 4878 } | 5021 } |
| 4879 } | 5022 } |
| 4880 | 5023 |
| 5024 @override |
| 4881 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 5025 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 4882 if (node.parent is! DefaultFormalParameter) { | 5026 if (node.parent is! DefaultFormalParameter) { |
| 4883 SimpleIdentifier parameterName = node.identifier; | 5027 SimpleIdentifier parameterName = node.identifier; |
| 4884 ParameterElement element = _getElementForParameter(node, parameterName); | 5028 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4885 ParameterElement outerParameter = _enclosingParameter; | 5029 ParameterElement outerParameter = _enclosingParameter; |
| 4886 try { | 5030 try { |
| 4887 _enclosingParameter = element; | 5031 _enclosingParameter = element; |
| 4888 return super.visitFunctionTypedFormalParameter(node); | 5032 return super.visitFunctionTypedFormalParameter(node); |
| 4889 } finally { | 5033 } finally { |
| 4890 _enclosingParameter = outerParameter; | 5034 _enclosingParameter = outerParameter; |
| 4891 } | 5035 } |
| 4892 } else { | 5036 } else { |
| 4893 return super.visitFunctionTypedFormalParameter(node); | 5037 return super.visitFunctionTypedFormalParameter(node); |
| 4894 } | 5038 } |
| 4895 } | 5039 } |
| 4896 | 5040 |
| 5041 @override |
| 4897 Object visitImportDirective(ImportDirective node) { | 5042 Object visitImportDirective(ImportDirective node) { |
| 4898 String uri = _getStringValue(node.uri); | 5043 String uri = _getStringValue(node.uri); |
| 4899 if (uri != null) { | 5044 if (uri != null) { |
| 4900 LibraryElement library = _enclosingUnit.library; | 5045 LibraryElement library = _enclosingUnit.library; |
| 4901 ImportElement importElement = _findImport(library.imports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri), node.prefix); | 5046 ImportElement importElement = _findImport(library.imports, _enclosingUnit.
context.sourceFactory.resolveUri(_enclosingUnit.source, uri), node.prefix); |
| 4902 node.element = importElement; | 5047 node.element = importElement; |
| 4903 } | 5048 } |
| 4904 return super.visitImportDirective(node); | 5049 return super.visitImportDirective(node); |
| 4905 } | 5050 } |
| 4906 | 5051 |
| 5052 @override |
| 4907 Object visitLabeledStatement(LabeledStatement node) { | 5053 Object visitLabeledStatement(LabeledStatement node) { |
| 4908 for (Label label in node.labels) { | 5054 for (Label label in node.labels) { |
| 4909 SimpleIdentifier labelName = label.label; | 5055 SimpleIdentifier labelName = label.label; |
| 4910 _findIdentifier(_enclosingExecutable.labels, labelName); | 5056 _findIdentifier(_enclosingExecutable.labels, labelName); |
| 4911 } | 5057 } |
| 4912 return super.visitLabeledStatement(node); | 5058 return super.visitLabeledStatement(node); |
| 4913 } | 5059 } |
| 4914 | 5060 |
| 5061 @override |
| 4915 Object visitLibraryDirective(LibraryDirective node) { | 5062 Object visitLibraryDirective(LibraryDirective node) { |
| 4916 node.element = _enclosingUnit.library; | 5063 node.element = _enclosingUnit.library; |
| 4917 return super.visitLibraryDirective(node); | 5064 return super.visitLibraryDirective(node); |
| 4918 } | 5065 } |
| 4919 | 5066 |
| 5067 @override |
| 4920 Object visitMethodDeclaration(MethodDeclaration node) { | 5068 Object visitMethodDeclaration(MethodDeclaration node) { |
| 4921 ExecutableElement outerExecutable = _enclosingExecutable; | 5069 ExecutableElement outerExecutable = _enclosingExecutable; |
| 4922 try { | 5070 try { |
| 4923 sc.Token property = node.propertyKeyword; | 5071 sc.Token property = node.propertyKeyword; |
| 4924 SimpleIdentifier methodName = node.name; | 5072 SimpleIdentifier methodName = node.name; |
| 4925 String nameOfMethod = methodName.name; | 5073 String nameOfMethod = methodName.name; |
| 4926 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { | 5074 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter
s.length == 0) { |
| 4927 nameOfMethod = "unary-"; | 5075 nameOfMethod = "unary-"; |
| 4928 } | 5076 } |
| 4929 if (property == null) { | 5077 if (property == null) { |
| 4930 _enclosingExecutable = _findWithNameAndOffset(_enclosingClass.methods, n
ameOfMethod, methodName.offset); | 5078 _enclosingExecutable = _findWithNameAndOffset(_enclosingClass.methods, n
ameOfMethod, methodName.offset); |
| 4931 methodName.staticElement = _enclosingExecutable; | 5079 methodName.staticElement = _enclosingExecutable; |
| 4932 } else { | 5080 } else { |
| 4933 PropertyAccessorElement accessor = _findIdentifier(_enclosingClass.acces
sors, methodName); | 5081 PropertyAccessorElement accessor = _findIdentifier(_enclosingClass.acces
sors, methodName); |
| 4934 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { | 5082 if (identical((property as sc.KeywordToken).keyword, sc.Keyword.SET)) { |
| 4935 accessor = accessor.variable.setter; | 5083 accessor = accessor.variable.setter; |
| 4936 methodName.staticElement = accessor; | 5084 methodName.staticElement = accessor; |
| 4937 } | 5085 } |
| 4938 _enclosingExecutable = accessor; | 5086 _enclosingExecutable = accessor; |
| 4939 } | 5087 } |
| 4940 return super.visitMethodDeclaration(node); | 5088 return super.visitMethodDeclaration(node); |
| 4941 } finally { | 5089 } finally { |
| 4942 _enclosingExecutable = outerExecutable; | 5090 _enclosingExecutable = outerExecutable; |
| 4943 } | 5091 } |
| 4944 } | 5092 } |
| 4945 | 5093 |
| 5094 @override |
| 4946 Object visitPartDirective(PartDirective node) { | 5095 Object visitPartDirective(PartDirective node) { |
| 4947 String uri = _getStringValue(node.uri); | 5096 String uri = _getStringValue(node.uri); |
| 4948 if (uri != null) { | 5097 if (uri != null) { |
| 4949 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri); | 5098 Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(_enclo
singUnit.source, uri); |
| 4950 node.element = _findPart(_enclosingUnit.library.parts, partSource); | 5099 node.element = _findPart(_enclosingUnit.library.parts, partSource); |
| 4951 } | 5100 } |
| 4952 return super.visitPartDirective(node); | 5101 return super.visitPartDirective(node); |
| 4953 } | 5102 } |
| 4954 | 5103 |
| 5104 @override |
| 4955 Object visitPartOfDirective(PartOfDirective node) { | 5105 Object visitPartOfDirective(PartOfDirective node) { |
| 4956 node.element = _enclosingUnit.library; | 5106 node.element = _enclosingUnit.library; |
| 4957 return super.visitPartOfDirective(node); | 5107 return super.visitPartOfDirective(node); |
| 4958 } | 5108 } |
| 4959 | 5109 |
| 5110 @override |
| 4960 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 5111 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 4961 if (node.parent is! DefaultFormalParameter) { | 5112 if (node.parent is! DefaultFormalParameter) { |
| 4962 SimpleIdentifier parameterName = node.identifier; | 5113 SimpleIdentifier parameterName = node.identifier; |
| 4963 ParameterElement element = _getElementForParameter(node, parameterName); | 5114 ParameterElement element = _getElementForParameter(node, parameterName); |
| 4964 ParameterElement outerParameter = _enclosingParameter; | 5115 ParameterElement outerParameter = _enclosingParameter; |
| 4965 try { | 5116 try { |
| 4966 _enclosingParameter = element; | 5117 _enclosingParameter = element; |
| 4967 return super.visitSimpleFormalParameter(node); | 5118 return super.visitSimpleFormalParameter(node); |
| 4968 } finally { | 5119 } finally { |
| 4969 _enclosingParameter = outerParameter; | 5120 _enclosingParameter = outerParameter; |
| 4970 } | 5121 } |
| 4971 } else { | 5122 } else { |
| 4972 } | 5123 } |
| 4973 return super.visitSimpleFormalParameter(node); | 5124 return super.visitSimpleFormalParameter(node); |
| 4974 } | 5125 } |
| 4975 | 5126 |
| 5127 @override |
| 4976 Object visitSwitchCase(SwitchCase node) { | 5128 Object visitSwitchCase(SwitchCase node) { |
| 4977 for (Label label in node.labels) { | 5129 for (Label label in node.labels) { |
| 4978 SimpleIdentifier labelName = label.label; | 5130 SimpleIdentifier labelName = label.label; |
| 4979 _findIdentifier(_enclosingExecutable.labels, labelName); | 5131 _findIdentifier(_enclosingExecutable.labels, labelName); |
| 4980 } | 5132 } |
| 4981 return super.visitSwitchCase(node); | 5133 return super.visitSwitchCase(node); |
| 4982 } | 5134 } |
| 4983 | 5135 |
| 5136 @override |
| 4984 Object visitSwitchDefault(SwitchDefault node) { | 5137 Object visitSwitchDefault(SwitchDefault node) { |
| 4985 for (Label label in node.labels) { | 5138 for (Label label in node.labels) { |
| 4986 SimpleIdentifier labelName = label.label; | 5139 SimpleIdentifier labelName = label.label; |
| 4987 _findIdentifier(_enclosingExecutable.labels, labelName); | 5140 _findIdentifier(_enclosingExecutable.labels, labelName); |
| 4988 } | 5141 } |
| 4989 return super.visitSwitchDefault(node); | 5142 return super.visitSwitchDefault(node); |
| 4990 } | 5143 } |
| 4991 | 5144 |
| 5145 @override |
| 4992 Object visitTypeParameter(TypeParameter node) { | 5146 Object visitTypeParameter(TypeParameter node) { |
| 4993 SimpleIdentifier parameterName = node.name; | 5147 SimpleIdentifier parameterName = node.name; |
| 4994 if (_enclosingClass != null) { | 5148 if (_enclosingClass != null) { |
| 4995 _findIdentifier(_enclosingClass.typeParameters, parameterName); | 5149 _findIdentifier(_enclosingClass.typeParameters, parameterName); |
| 4996 } else if (_enclosingAlias != null) { | 5150 } else if (_enclosingAlias != null) { |
| 4997 _findIdentifier(_enclosingAlias.typeParameters, parameterName); | 5151 _findIdentifier(_enclosingAlias.typeParameters, parameterName); |
| 4998 } | 5152 } |
| 4999 return super.visitTypeParameter(node); | 5153 return super.visitTypeParameter(node); |
| 5000 } | 5154 } |
| 5001 | 5155 |
| 5156 @override |
| 5002 Object visitVariableDeclaration(VariableDeclaration node) { | 5157 Object visitVariableDeclaration(VariableDeclaration node) { |
| 5003 VariableElement element = null; | 5158 VariableElement element = null; |
| 5004 SimpleIdentifier variableName = node.name; | 5159 SimpleIdentifier variableName = node.name; |
| 5005 if (_enclosingExecutable != null) { | 5160 if (_enclosingExecutable != null) { |
| 5006 element = _findIdentifier(_enclosingExecutable.localVariables, variableNam
e); | 5161 element = _findIdentifier(_enclosingExecutable.localVariables, variableNam
e); |
| 5007 } | 5162 } |
| 5008 if (element == null && _enclosingClass != null) { | 5163 if (element == null && _enclosingClass != null) { |
| 5009 element = _findIdentifier(_enclosingClass.fields, variableName); | 5164 element = _findIdentifier(_enclosingClass.fields, variableName); |
| 5010 } | 5165 } |
| 5011 if (element == null && _enclosingUnit != null) { | 5166 if (element == null && _enclosingUnit != null) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 this._resolver = resolver; | 5516 this._resolver = resolver; |
| 5362 this._definingLibrary = resolver.definingLibrary; | 5517 this._definingLibrary = resolver.definingLibrary; |
| 5363 AnalysisOptions options = _definingLibrary.context.analysisOptions; | 5518 AnalysisOptions options = _definingLibrary.context.analysisOptions; |
| 5364 _enableHints = options.hint; | 5519 _enableHints = options.hint; |
| 5365 _dynamicType = resolver.typeProvider.dynamicType; | 5520 _dynamicType = resolver.typeProvider.dynamicType; |
| 5366 _typeType = resolver.typeProvider.typeType; | 5521 _typeType = resolver.typeProvider.typeType; |
| 5367 _subtypeManager = new SubtypeManager(); | 5522 _subtypeManager = new SubtypeManager(); |
| 5368 _promoteManager = resolver.promoteManager; | 5523 _promoteManager = resolver.promoteManager; |
| 5369 } | 5524 } |
| 5370 | 5525 |
| 5526 @override |
| 5371 Object visitAssignmentExpression(AssignmentExpression node) { | 5527 Object visitAssignmentExpression(AssignmentExpression node) { |
| 5372 sc.Token operator = node.operator; | 5528 sc.Token operator = node.operator; |
| 5373 sc.TokenType operatorType = operator.type; | 5529 sc.TokenType operatorType = operator.type; |
| 5374 if (operatorType != sc.TokenType.EQ) { | 5530 if (operatorType != sc.TokenType.EQ) { |
| 5375 operatorType = _operatorFromCompoundAssignment(operatorType); | 5531 operatorType = _operatorFromCompoundAssignment(operatorType); |
| 5376 Expression leftHandSide = node.leftHandSide; | 5532 Expression leftHandSide = node.leftHandSide; |
| 5377 if (leftHandSide != null) { | 5533 if (leftHandSide != null) { |
| 5378 String methodName = operatorType.lexeme; | 5534 String methodName = operatorType.lexeme; |
| 5379 DartType staticType = _getStaticType(leftHandSide); | 5535 DartType staticType = _getStaticType(leftHandSide); |
| 5380 MethodElement staticMethod = _lookUpMethod(leftHandSide, staticType, met
hodName); | 5536 MethodElement staticMethod = _lookUpMethod(leftHandSide, staticType, met
hodName); |
| 5381 node.staticElement = staticMethod; | 5537 node.staticElement = staticMethod; |
| 5382 DartType propagatedType = _getPropagatedType(leftHandSide); | 5538 DartType propagatedType = _getPropagatedType(leftHandSide); |
| 5383 MethodElement propagatedMethod = _lookUpMethod(leftHandSide, propagatedT
ype, methodName); | 5539 MethodElement propagatedMethod = _lookUpMethod(leftHandSide, propagatedT
ype, methodName); |
| 5384 node.propagatedElement = propagatedMethod; | 5540 node.propagatedElement = propagatedMethod; |
| 5385 if (_shouldReportMissingMember(staticType, staticMethod)) { | 5541 if (_shouldReportMissingMember(staticType, staticMethod)) { |
| 5386 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_METHOD, operator, [methodName, staticType.displ
ayName]); | 5542 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_METHOD, operator, [methodName, staticType.displ
ayName]); |
| 5387 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr
opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t
rue, false)) { | 5543 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr
opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t
rue, false)) { |
| 5388 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elem
ent, HintCode.UNDEFINED_METHOD, operator, [methodName, propagatedType.displayNam
e]); | 5544 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elem
ent, HintCode.UNDEFINED_METHOD, operator, [methodName, propagatedType.displayNam
e]); |
| 5389 } | 5545 } |
| 5390 } | 5546 } |
| 5391 } | 5547 } |
| 5392 return null; | 5548 return null; |
| 5393 } | 5549 } |
| 5394 | 5550 |
| 5551 @override |
| 5395 Object visitBinaryExpression(BinaryExpression node) { | 5552 Object visitBinaryExpression(BinaryExpression node) { |
| 5396 sc.Token operator = node.operator; | 5553 sc.Token operator = node.operator; |
| 5397 if (operator.isUserDefinableOperator) { | 5554 if (operator.isUserDefinableOperator) { |
| 5398 Expression leftOperand = node.leftOperand; | 5555 Expression leftOperand = node.leftOperand; |
| 5399 if (leftOperand != null) { | 5556 if (leftOperand != null) { |
| 5400 String methodName = operator.lexeme; | 5557 String methodName = operator.lexeme; |
| 5401 DartType staticType = _getStaticType(leftOperand); | 5558 DartType staticType = _getStaticType(leftOperand); |
| 5402 MethodElement staticMethod = _lookUpMethod(leftOperand, staticType, meth
odName); | 5559 MethodElement staticMethod = _lookUpMethod(leftOperand, staticType, meth
odName); |
| 5403 node.staticElement = staticMethod; | 5560 node.staticElement = staticMethod; |
| 5404 DartType propagatedType = _getPropagatedType(leftOperand); | 5561 DartType propagatedType = _getPropagatedType(leftOperand); |
| 5405 MethodElement propagatedMethod = _lookUpMethod(leftOperand, propagatedTy
pe, methodName); | 5562 MethodElement propagatedMethod = _lookUpMethod(leftOperand, propagatedTy
pe, methodName); |
| 5406 node.propagatedElement = propagatedMethod; | 5563 node.propagatedElement = propagatedMethod; |
| 5407 if (_shouldReportMissingMember(staticType, staticMethod)) { | 5564 if (_shouldReportMissingMember(staticType, staticMethod)) { |
| 5408 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.dis
playName]); | 5565 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.dis
playName]); |
| 5409 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr
opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t
rue, false)) { | 5566 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr
opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t
rue, false)) { |
| 5410 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elem
ent, HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayN
ame]); | 5567 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elem
ent, HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayN
ame]); |
| 5411 } | 5568 } |
| 5412 } | 5569 } |
| 5413 } | 5570 } |
| 5414 return null; | 5571 return null; |
| 5415 } | 5572 } |
| 5416 | 5573 |
| 5574 @override |
| 5417 Object visitBreakStatement(BreakStatement node) { | 5575 Object visitBreakStatement(BreakStatement node) { |
| 5418 _lookupLabel(node, node.label); | 5576 _lookupLabel(node, node.label); |
| 5419 return null; | 5577 return null; |
| 5420 } | 5578 } |
| 5421 | 5579 |
| 5580 @override |
| 5422 Object visitClassDeclaration(ClassDeclaration node) { | 5581 Object visitClassDeclaration(ClassDeclaration node) { |
| 5423 _setMetadata(node.element, node); | 5582 _setMetadata(node.element, node); |
| 5424 return null; | 5583 return null; |
| 5425 } | 5584 } |
| 5426 | 5585 |
| 5586 @override |
| 5427 Object visitClassTypeAlias(ClassTypeAlias node) { | 5587 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 5428 _setMetadata(node.element, node); | 5588 _setMetadata(node.element, node); |
| 5429 return null; | 5589 return null; |
| 5430 } | 5590 } |
| 5431 | 5591 |
| 5592 @override |
| 5432 Object visitCommentReference(CommentReference node) { | 5593 Object visitCommentReference(CommentReference node) { |
| 5433 Identifier identifier = node.identifier; | 5594 Identifier identifier = node.identifier; |
| 5434 if (identifier is SimpleIdentifier) { | 5595 if (identifier is SimpleIdentifier) { |
| 5435 SimpleIdentifier simpleIdentifier = identifier; | 5596 SimpleIdentifier simpleIdentifier = identifier; |
| 5436 Element element = _resolveSimpleIdentifier(simpleIdentifier); | 5597 Element element = _resolveSimpleIdentifier(simpleIdentifier); |
| 5437 if (element == null) { | 5598 if (element == null) { |
| 5438 // | 5599 // |
| 5439 // This might be a reference to an imported name that is missing the pre
fix. | 5600 // This might be a reference to an imported name that is missing the pre
fix. |
| 5440 // | 5601 // |
| 5441 element = _findImportWithoutPrefix(simpleIdentifier); | 5602 element = _findImportWithoutPrefix(simpleIdentifier); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5504 name.staticElement = constructor; | 5665 name.staticElement = constructor; |
| 5505 } | 5666 } |
| 5506 } else { | 5667 } else { |
| 5507 } | 5668 } |
| 5508 } | 5669 } |
| 5509 } | 5670 } |
| 5510 } | 5671 } |
| 5511 return null; | 5672 return null; |
| 5512 } | 5673 } |
| 5513 | 5674 |
| 5675 @override |
| 5514 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 5676 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 5515 super.visitConstructorDeclaration(node); | 5677 super.visitConstructorDeclaration(node); |
| 5516 ConstructorElement element = node.element; | 5678 ConstructorElement element = node.element; |
| 5517 if (element is ConstructorElementImpl) { | 5679 if (element is ConstructorElementImpl) { |
| 5518 ConstructorElementImpl constructorElement = element; | 5680 ConstructorElementImpl constructorElement = element; |
| 5519 ConstructorName redirectedNode = node.redirectedConstructor; | 5681 ConstructorName redirectedNode = node.redirectedConstructor; |
| 5520 if (redirectedNode != null) { | 5682 if (redirectedNode != null) { |
| 5521 // set redirected factory constructor | 5683 // set redirected factory constructor |
| 5522 ConstructorElement redirectedElement = redirectedNode.staticElement; | 5684 ConstructorElement redirectedElement = redirectedNode.staticElement; |
| 5523 constructorElement.redirectedConstructor = redirectedElement; | 5685 constructorElement.redirectedConstructor = redirectedElement; |
| 5524 } else { | 5686 } else { |
| 5525 // set redirected generative constructor | 5687 // set redirected generative constructor |
| 5526 for (ConstructorInitializer initializer in node.initializers) { | 5688 for (ConstructorInitializer initializer in node.initializers) { |
| 5527 if (initializer is RedirectingConstructorInvocation) { | 5689 if (initializer is RedirectingConstructorInvocation) { |
| 5528 ConstructorElement redirectedElement = initializer.staticElement; | 5690 ConstructorElement redirectedElement = initializer.staticElement; |
| 5529 constructorElement.redirectedConstructor = redirectedElement; | 5691 constructorElement.redirectedConstructor = redirectedElement; |
| 5530 } | 5692 } |
| 5531 } | 5693 } |
| 5532 } | 5694 } |
| 5533 _setMetadata(constructorElement, node); | 5695 _setMetadata(constructorElement, node); |
| 5534 } | 5696 } |
| 5535 return null; | 5697 return null; |
| 5536 } | 5698 } |
| 5537 | 5699 |
| 5700 @override |
| 5538 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 5701 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 5539 SimpleIdentifier fieldName = node.fieldName; | 5702 SimpleIdentifier fieldName = node.fieldName; |
| 5540 ClassElement enclosingClass = _resolver.enclosingClass; | 5703 ClassElement enclosingClass = _resolver.enclosingClass; |
| 5541 FieldElement fieldElement = enclosingClass.getField(fieldName.name); | 5704 FieldElement fieldElement = enclosingClass.getField(fieldName.name); |
| 5542 fieldName.staticElement = fieldElement; | 5705 fieldName.staticElement = fieldElement; |
| 5543 return null; | 5706 return null; |
| 5544 } | 5707 } |
| 5545 | 5708 |
| 5709 @override |
| 5546 Object visitConstructorName(ConstructorName node) { | 5710 Object visitConstructorName(ConstructorName node) { |
| 5547 DartType type = node.type.type; | 5711 DartType type = node.type.type; |
| 5548 if (type != null && type.isDynamic) { | 5712 if (type != null && type.isDynamic) { |
| 5549 return null; | 5713 return null; |
| 5550 } else if (type is! InterfaceType) { | 5714 } else if (type is! InterfaceType) { |
| 5551 // TODO(brianwilkerson) Report these errors. | 5715 // TODO(brianwilkerson) Report these errors. |
| 5552 // ASTNode parent = node.getParent(); | 5716 // ASTNode parent = node.getParent(); |
| 5553 // if (parent instanceof InstanceCreationExpression) { | 5717 // if (parent instanceof InstanceCreationExpression) { |
| 5554 // if (((InstanceCreationExpression) parent).isConst()) { | 5718 // if (((InstanceCreationExpression) parent).isConst()) { |
| 5555 // // CompileTimeErrorCode.CONST_WITH_NON_TYPE | 5719 // // CompileTimeErrorCode.CONST_WITH_NON_TYPE |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5568 if (name == null) { | 5732 if (name == null) { |
| 5569 constructor = interfaceType.lookUpConstructor(null, _definingLibrary); | 5733 constructor = interfaceType.lookUpConstructor(null, _definingLibrary); |
| 5570 } else { | 5734 } else { |
| 5571 constructor = interfaceType.lookUpConstructor(name.name, _definingLibrary)
; | 5735 constructor = interfaceType.lookUpConstructor(name.name, _definingLibrary)
; |
| 5572 name.staticElement = constructor; | 5736 name.staticElement = constructor; |
| 5573 } | 5737 } |
| 5574 node.staticElement = constructor; | 5738 node.staticElement = constructor; |
| 5575 return null; | 5739 return null; |
| 5576 } | 5740 } |
| 5577 | 5741 |
| 5742 @override |
| 5578 Object visitContinueStatement(ContinueStatement node) { | 5743 Object visitContinueStatement(ContinueStatement node) { |
| 5579 _lookupLabel(node, node.label); | 5744 _lookupLabel(node, node.label); |
| 5580 return null; | 5745 return null; |
| 5581 } | 5746 } |
| 5582 | 5747 |
| 5748 @override |
| 5583 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 5749 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 5584 _setMetadata(node.element, node); | 5750 _setMetadata(node.element, node); |
| 5585 return null; | 5751 return null; |
| 5586 } | 5752 } |
| 5587 | 5753 |
| 5754 @override |
| 5588 Object visitExportDirective(ExportDirective node) { | 5755 Object visitExportDirective(ExportDirective node) { |
| 5589 ExportElement exportElement = node.element; | 5756 ExportElement exportElement = node.element; |
| 5590 if (exportElement != null) { | 5757 if (exportElement != null) { |
| 5591 // The element is null when the URI is invalid | 5758 // The element is null when the URI is invalid |
| 5592 // TODO(brianwilkerson) Figure out whether the element can ever be somethi
ng other than an | 5759 // TODO(brianwilkerson) Figure out whether the element can ever be somethi
ng other than an |
| 5593 // ExportElement | 5760 // ExportElement |
| 5594 _resolveCombinators(exportElement.exportedLibrary, node.combinators); | 5761 _resolveCombinators(exportElement.exportedLibrary, node.combinators); |
| 5595 _setMetadata(exportElement, node); | 5762 _setMetadata(exportElement, node); |
| 5596 } | 5763 } |
| 5597 return null; | 5764 return null; |
| 5598 } | 5765 } |
| 5599 | 5766 |
| 5767 @override |
| 5600 Object visitFieldFormalParameter(FieldFormalParameter node) { | 5768 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 5601 _setMetadataForParameter(node.element, node); | 5769 _setMetadataForParameter(node.element, node); |
| 5602 return super.visitFieldFormalParameter(node); | 5770 return super.visitFieldFormalParameter(node); |
| 5603 } | 5771 } |
| 5604 | 5772 |
| 5773 @override |
| 5605 Object visitFunctionDeclaration(FunctionDeclaration node) { | 5774 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 5606 _setMetadata(node.element, node); | 5775 _setMetadata(node.element, node); |
| 5607 return null; | 5776 return null; |
| 5608 } | 5777 } |
| 5609 | 5778 |
| 5779 @override |
| 5610 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 5780 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 5611 // TODO(brianwilkerson) Can we ever resolve the function being invoked? | 5781 // TODO(brianwilkerson) Can we ever resolve the function being invoked? |
| 5612 Expression expression = node.function; | 5782 Expression expression = node.function; |
| 5613 if (expression is FunctionExpression) { | 5783 if (expression is FunctionExpression) { |
| 5614 FunctionExpression functionExpression = expression; | 5784 FunctionExpression functionExpression = expression; |
| 5615 ExecutableElement functionElement = functionExpression.element; | 5785 ExecutableElement functionElement = functionExpression.element; |
| 5616 ArgumentList argumentList = node.argumentList; | 5786 ArgumentList argumentList = node.argumentList; |
| 5617 List<ParameterElement> parameters = _resolveArgumentsToFunction(false, arg
umentList, functionElement); | 5787 List<ParameterElement> parameters = _resolveArgumentsToFunction(false, arg
umentList, functionElement); |
| 5618 if (parameters != null) { | 5788 if (parameters != null) { |
| 5619 argumentList.correspondingStaticParameters = parameters; | 5789 argumentList.correspondingStaticParameters = parameters; |
| 5620 } | 5790 } |
| 5621 } | 5791 } |
| 5622 return null; | 5792 return null; |
| 5623 } | 5793 } |
| 5624 | 5794 |
| 5795 @override |
| 5625 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 5796 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 5626 _setMetadata(node.element, node); | 5797 _setMetadata(node.element, node); |
| 5627 return null; | 5798 return null; |
| 5628 } | 5799 } |
| 5629 | 5800 |
| 5801 @override |
| 5630 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 5802 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 5631 _setMetadataForParameter(node.element, node); | 5803 _setMetadataForParameter(node.element, node); |
| 5632 return null; | 5804 return null; |
| 5633 } | 5805 } |
| 5634 | 5806 |
| 5807 @override |
| 5635 Object visitImportDirective(ImportDirective node) { | 5808 Object visitImportDirective(ImportDirective node) { |
| 5636 SimpleIdentifier prefixNode = node.prefix; | 5809 SimpleIdentifier prefixNode = node.prefix; |
| 5637 if (prefixNode != null) { | 5810 if (prefixNode != null) { |
| 5638 String prefixName = prefixNode.name; | 5811 String prefixName = prefixNode.name; |
| 5639 for (PrefixElement prefixElement in _definingLibrary.prefixes) { | 5812 for (PrefixElement prefixElement in _definingLibrary.prefixes) { |
| 5640 if (prefixElement.displayName == prefixName) { | 5813 if (prefixElement.displayName == prefixName) { |
| 5641 prefixNode.staticElement = prefixElement; | 5814 prefixNode.staticElement = prefixElement; |
| 5642 break; | 5815 break; |
| 5643 } | 5816 } |
| 5644 } | 5817 } |
| 5645 } | 5818 } |
| 5646 ImportElement importElement = node.element; | 5819 ImportElement importElement = node.element; |
| 5647 if (importElement != null) { | 5820 if (importElement != null) { |
| 5648 // The element is null when the URI is invalid | 5821 // The element is null when the URI is invalid |
| 5649 LibraryElement library = importElement.importedLibrary; | 5822 LibraryElement library = importElement.importedLibrary; |
| 5650 if (library != null) { | 5823 if (library != null) { |
| 5651 _resolveCombinators(library, node.combinators); | 5824 _resolveCombinators(library, node.combinators); |
| 5652 } | 5825 } |
| 5653 _setMetadata(importElement, node); | 5826 _setMetadata(importElement, node); |
| 5654 } | 5827 } |
| 5655 return null; | 5828 return null; |
| 5656 } | 5829 } |
| 5657 | 5830 |
| 5831 @override |
| 5658 Object visitIndexExpression(IndexExpression node) { | 5832 Object visitIndexExpression(IndexExpression node) { |
| 5659 Expression target = node.realTarget; | 5833 Expression target = node.realTarget; |
| 5660 DartType staticType = _getStaticType(target); | 5834 DartType staticType = _getStaticType(target); |
| 5661 DartType propagatedType = _getPropagatedType(target); | 5835 DartType propagatedType = _getPropagatedType(target); |
| 5662 String getterMethodName = sc.TokenType.INDEX.lexeme; | 5836 String getterMethodName = sc.TokenType.INDEX.lexeme; |
| 5663 String setterMethodName = sc.TokenType.INDEX_EQ.lexeme; | 5837 String setterMethodName = sc.TokenType.INDEX_EQ.lexeme; |
| 5664 bool isInGetterContext = node.inGetterContext(); | 5838 bool isInGetterContext = node.inGetterContext(); |
| 5665 bool isInSetterContext = node.inSetterContext(); | 5839 bool isInSetterContext = node.inSetterContext(); |
| 5666 if (isInGetterContext && isInSetterContext) { | 5840 if (isInGetterContext && isInSetterContext) { |
| 5667 // lookup setter | 5841 // lookup setter |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5695 MethodElement propagatedMethod = _lookUpMethod(target, propagatedType, set
terMethodName); | 5869 MethodElement propagatedMethod = _lookUpMethod(target, propagatedType, set
terMethodName); |
| 5696 // set setter element | 5870 // set setter element |
| 5697 node.staticElement = staticMethod; | 5871 node.staticElement = staticMethod; |
| 5698 node.propagatedElement = propagatedMethod; | 5872 node.propagatedElement = propagatedMethod; |
| 5699 // generate undefined method warning | 5873 // generate undefined method warning |
| 5700 _checkForUndefinedIndexOperator(node, target, setterMethodName, staticMeth
od, propagatedMethod, staticType, propagatedType); | 5874 _checkForUndefinedIndexOperator(node, target, setterMethodName, staticMeth
od, propagatedMethod, staticType, propagatedType); |
| 5701 } | 5875 } |
| 5702 return null; | 5876 return null; |
| 5703 } | 5877 } |
| 5704 | 5878 |
| 5879 @override |
| 5705 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 5880 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 5706 ConstructorElement invokedConstructor = node.constructorName.staticElement; | 5881 ConstructorElement invokedConstructor = node.constructorName.staticElement; |
| 5707 node.staticElement = invokedConstructor; | 5882 node.staticElement = invokedConstructor; |
| 5708 ArgumentList argumentList = node.argumentList; | 5883 ArgumentList argumentList = node.argumentList; |
| 5709 List<ParameterElement> parameters = _resolveArgumentsToFunction(node.isConst
, argumentList, invokedConstructor); | 5884 List<ParameterElement> parameters = _resolveArgumentsToFunction(node.isConst
, argumentList, invokedConstructor); |
| 5710 if (parameters != null) { | 5885 if (parameters != null) { |
| 5711 argumentList.correspondingStaticParameters = parameters; | 5886 argumentList.correspondingStaticParameters = parameters; |
| 5712 } | 5887 } |
| 5713 return null; | 5888 return null; |
| 5714 } | 5889 } |
| 5715 | 5890 |
| 5891 @override |
| 5716 Object visitLibraryDirective(LibraryDirective node) { | 5892 Object visitLibraryDirective(LibraryDirective node) { |
| 5717 _setMetadata(node.element, node); | 5893 _setMetadata(node.element, node); |
| 5718 return null; | 5894 return null; |
| 5719 } | 5895 } |
| 5720 | 5896 |
| 5897 @override |
| 5721 Object visitMethodDeclaration(MethodDeclaration node) { | 5898 Object visitMethodDeclaration(MethodDeclaration node) { |
| 5722 _setMetadata(node.element, node); | 5899 _setMetadata(node.element, node); |
| 5723 return null; | 5900 return null; |
| 5724 } | 5901 } |
| 5725 | 5902 |
| 5903 @override |
| 5726 Object visitMethodInvocation(MethodInvocation node) { | 5904 Object visitMethodInvocation(MethodInvocation node) { |
| 5727 SimpleIdentifier methodName = node.methodName; | 5905 SimpleIdentifier methodName = node.methodName; |
| 5728 // | 5906 // |
| 5729 // Synthetic identifiers have been already reported during parsing. | 5907 // Synthetic identifiers have been already reported during parsing. |
| 5730 // | 5908 // |
| 5731 if (methodName.isSynthetic) { | 5909 if (methodName.isSynthetic) { |
| 5732 return null; | 5910 return null; |
| 5733 } | 5911 } |
| 5734 // | 5912 // |
| 5735 // We have a method invocation of one of two forms: 'e.m(a1, ..., an)' or 'm
(a1, ..., an)'. The | 5913 // We have a method invocation of one of two forms: 'e.m(a1, ..., an)' or 'm
(a1, ..., an)'. The |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5851 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { | 6029 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { |
| 5852 // Generate the type name. | 6030 // Generate the type name. |
| 5853 // The error code will never be generated via type propagation | 6031 // The error code will never be generated via type propagation |
| 5854 DartType targetType = _getStaticType(target); | 6032 DartType targetType = _getStaticType(target); |
| 5855 String targetTypeName = targetType == null ? null : targetType.name; | 6033 String targetTypeName = targetType == null ? null : targetType.name; |
| 5856 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD,
methodName, [methodName.name, targetTypeName]); | 6034 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD,
methodName, [methodName.name, targetTypeName]); |
| 5857 } | 6035 } |
| 5858 return null; | 6036 return null; |
| 5859 } | 6037 } |
| 5860 | 6038 |
| 6039 @override |
| 5861 Object visitPartDirective(PartDirective node) { | 6040 Object visitPartDirective(PartDirective node) { |
| 5862 _setMetadata(node.element, node); | 6041 _setMetadata(node.element, node); |
| 5863 return null; | 6042 return null; |
| 5864 } | 6043 } |
| 5865 | 6044 |
| 6045 @override |
| 5866 Object visitPartOfDirective(PartOfDirective node) { | 6046 Object visitPartOfDirective(PartOfDirective node) { |
| 5867 _setMetadata(node.element, node); | 6047 _setMetadata(node.element, node); |
| 5868 return null; | 6048 return null; |
| 5869 } | 6049 } |
| 5870 | 6050 |
| 6051 @override |
| 5871 Object visitPostfixExpression(PostfixExpression node) { | 6052 Object visitPostfixExpression(PostfixExpression node) { |
| 5872 Expression operand = node.operand; | 6053 Expression operand = node.operand; |
| 5873 String methodName = _getPostfixOperator(node); | 6054 String methodName = _getPostfixOperator(node); |
| 5874 DartType staticType = _getStaticType(operand); | 6055 DartType staticType = _getStaticType(operand); |
| 5875 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName); | 6056 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName); |
| 5876 node.staticElement = staticMethod; | 6057 node.staticElement = staticMethod; |
| 5877 DartType propagatedType = _getPropagatedType(operand); | 6058 DartType propagatedType = _getPropagatedType(operand); |
| 5878 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, meth
odName); | 6059 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, meth
odName); |
| 5879 node.propagatedElement = propagatedMethod; | 6060 node.propagatedElement = propagatedMethod; |
| 5880 if (_shouldReportMissingMember(staticType, staticMethod)) { | 6061 if (_shouldReportMissingMember(staticType, staticMethod)) { |
| 5881 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, Sta
ticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.di
splayName]); | 6062 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, Sta
ticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.di
splayName]); |
| 5882 } else if (_enableHints && _shouldReportMissingMember(propagatedType, propag
atedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, true,
false)) { | 6063 } else if (_enableHints && _shouldReportMissingMember(propagatedType, propag
atedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, true,
false)) { |
| 5883 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.element,
HintCode.UNDEFINED_OPERATOR, node.operator, [methodName, propagatedType.display
Name]); | 6064 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.element,
HintCode.UNDEFINED_OPERATOR, node.operator, [methodName, propagatedType.display
Name]); |
| 5884 } | 6065 } |
| 5885 return null; | 6066 return null; |
| 5886 } | 6067 } |
| 5887 | 6068 |
| 6069 @override |
| 5888 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 6070 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 5889 SimpleIdentifier prefix = node.prefix; | 6071 SimpleIdentifier prefix = node.prefix; |
| 5890 SimpleIdentifier identifier = node.identifier; | 6072 SimpleIdentifier identifier = node.identifier; |
| 5891 // | 6073 // |
| 5892 // First, check to see whether the prefix is really a prefix. | 6074 // First, check to see whether the prefix is really a prefix. |
| 5893 // | 6075 // |
| 5894 Element prefixElement = prefix.staticElement; | 6076 Element prefixElement = prefix.staticElement; |
| 5895 if (prefixElement is PrefixElement) { | 6077 if (prefixElement is PrefixElement) { |
| 5896 Element element = _resolver.nameScope.lookup(node, _definingLibrary); | 6078 Element element = _resolver.nameScope.lookup(node, _definingLibrary); |
| 5897 if (element == null && identifier.inSetterContext()) { | 6079 if (element == null && identifier.inSetterContext()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5935 _resolveAnnotationElement(annotation); | 6117 _resolveAnnotationElement(annotation); |
| 5936 } | 6118 } |
| 5937 // | 6119 // |
| 5938 // Otherwise, the prefix is really an expression that happens to be a simple
identifier and this | 6120 // Otherwise, the prefix is really an expression that happens to be a simple
identifier and this |
| 5939 // is really equivalent to a property access node. | 6121 // is really equivalent to a property access node. |
| 5940 // | 6122 // |
| 5941 _resolvePropertyAccess(prefix, identifier); | 6123 _resolvePropertyAccess(prefix, identifier); |
| 5942 return null; | 6124 return null; |
| 5943 } | 6125 } |
| 5944 | 6126 |
| 6127 @override |
| 5945 Object visitPrefixExpression(PrefixExpression node) { | 6128 Object visitPrefixExpression(PrefixExpression node) { |
| 5946 sc.Token operator = node.operator; | 6129 sc.Token operator = node.operator; |
| 5947 sc.TokenType operatorType = operator.type; | 6130 sc.TokenType operatorType = operator.type; |
| 5948 if (operatorType.isUserDefinableOperator || identical(operatorType, sc.Token
Type.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { | 6131 if (operatorType.isUserDefinableOperator || identical(operatorType, sc.Token
Type.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { |
| 5949 Expression operand = node.operand; | 6132 Expression operand = node.operand; |
| 5950 String methodName = _getPrefixOperator(node); | 6133 String methodName = _getPrefixOperator(node); |
| 5951 DartType staticType = _getStaticType(operand); | 6134 DartType staticType = _getStaticType(operand); |
| 5952 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName
); | 6135 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName
); |
| 5953 node.staticElement = staticMethod; | 6136 node.staticElement = staticMethod; |
| 5954 DartType propagatedType = _getPropagatedType(operand); | 6137 DartType propagatedType = _getPropagatedType(operand); |
| 5955 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, me
thodName); | 6138 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, me
thodName); |
| 5956 node.propagatedElement = propagatedMethod; | 6139 node.propagatedElement = propagatedMethod; |
| 5957 if (_shouldReportMissingMember(staticType, staticMethod)) { | 6140 if (_shouldReportMissingMember(staticType, staticMethod)) { |
| 5958 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, S
taticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.displ
ayName]); | 6141 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, S
taticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.displ
ayName]); |
| 5959 } else if (_enableHints && _shouldReportMissingMember(propagatedType, prop
agatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, tru
e, false)) { | 6142 } else if (_enableHints && _shouldReportMissingMember(propagatedType, prop
agatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, tru
e, false)) { |
| 5960 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elemen
t, HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayNam
e]); | 6143 _resolver.reportErrorProxyConditionalAnalysisError(propagatedType.elemen
t, HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayNam
e]); |
| 5961 } | 6144 } |
| 5962 } | 6145 } |
| 5963 return null; | 6146 return null; |
| 5964 } | 6147 } |
| 5965 | 6148 |
| 6149 @override |
| 5966 Object visitPropertyAccess(PropertyAccess node) { | 6150 Object visitPropertyAccess(PropertyAccess node) { |
| 5967 Expression target = node.realTarget; | 6151 Expression target = node.realTarget; |
| 5968 if (target is SuperExpression && !_isSuperInValidContext(target)) { | 6152 if (target is SuperExpression && !_isSuperInValidContext(target)) { |
| 5969 return null; | 6153 return null; |
| 5970 } | 6154 } |
| 5971 SimpleIdentifier propertyName = node.propertyName; | 6155 SimpleIdentifier propertyName = node.propertyName; |
| 5972 _resolvePropertyAccess(target, propertyName); | 6156 _resolvePropertyAccess(target, propertyName); |
| 5973 return null; | 6157 return null; |
| 5974 } | 6158 } |
| 5975 | 6159 |
| 6160 @override |
| 5976 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 6161 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 5977 ClassElement enclosingClass = _resolver.enclosingClass; | 6162 ClassElement enclosingClass = _resolver.enclosingClass; |
| 5978 if (enclosingClass == null) { | 6163 if (enclosingClass == null) { |
| 5979 // TODO(brianwilkerson) Report this error. | 6164 // TODO(brianwilkerson) Report this error. |
| 5980 return null; | 6165 return null; |
| 5981 } | 6166 } |
| 5982 SimpleIdentifier name = node.constructorName; | 6167 SimpleIdentifier name = node.constructorName; |
| 5983 ConstructorElement element; | 6168 ConstructorElement element; |
| 5984 if (name == null) { | 6169 if (name == null) { |
| 5985 element = enclosingClass.unnamedConstructor; | 6170 element = enclosingClass.unnamedConstructor; |
| 5986 } else { | 6171 } else { |
| 5987 element = enclosingClass.getNamedConstructor(name.name); | 6172 element = enclosingClass.getNamedConstructor(name.name); |
| 5988 } | 6173 } |
| 5989 if (element == null) { | 6174 if (element == null) { |
| 5990 // TODO(brianwilkerson) Report this error and decide what element to assoc
iate with the node. | 6175 // TODO(brianwilkerson) Report this error and decide what element to assoc
iate with the node. |
| 5991 return null; | 6176 return null; |
| 5992 } | 6177 } |
| 5993 if (name != null) { | 6178 if (name != null) { |
| 5994 name.staticElement = element; | 6179 name.staticElement = element; |
| 5995 } | 6180 } |
| 5996 node.staticElement = element; | 6181 node.staticElement = element; |
| 5997 ArgumentList argumentList = node.argumentList; | 6182 ArgumentList argumentList = node.argumentList; |
| 5998 List<ParameterElement> parameters = _resolveArgumentsToFunction(false, argum
entList, element); | 6183 List<ParameterElement> parameters = _resolveArgumentsToFunction(false, argum
entList, element); |
| 5999 if (parameters != null) { | 6184 if (parameters != null) { |
| 6000 argumentList.correspondingStaticParameters = parameters; | 6185 argumentList.correspondingStaticParameters = parameters; |
| 6001 } | 6186 } |
| 6002 return null; | 6187 return null; |
| 6003 } | 6188 } |
| 6004 | 6189 |
| 6190 @override |
| 6005 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 6191 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 6006 _setMetadataForParameter(node.element, node); | 6192 _setMetadataForParameter(node.element, node); |
| 6007 return null; | 6193 return null; |
| 6008 } | 6194 } |
| 6009 | 6195 |
| 6196 @override |
| 6010 Object visitSimpleIdentifier(SimpleIdentifier node) { | 6197 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 6011 // | 6198 // |
| 6012 // Synthetic identifiers have been already reported during parsing. | 6199 // Synthetic identifiers have been already reported during parsing. |
| 6013 // | 6200 // |
| 6014 if (node.isSynthetic) { | 6201 if (node.isSynthetic) { |
| 6015 return null; | 6202 return null; |
| 6016 } | 6203 } |
| 6017 // | 6204 // |
| 6018 // We ignore identifiers that have already been resolved, such as identifier
s representing the | 6205 // We ignore identifiers that have already been resolved, such as identifier
s representing the |
| 6019 // name in a declaration. | 6206 // name in a declaration. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6059 // | 6246 // |
| 6060 // Validate annotation element. | 6247 // Validate annotation element. |
| 6061 // | 6248 // |
| 6062 if (node.parent is Annotation) { | 6249 if (node.parent is Annotation) { |
| 6063 Annotation annotation = node.parent as Annotation; | 6250 Annotation annotation = node.parent as Annotation; |
| 6064 _resolveAnnotationElement(annotation); | 6251 _resolveAnnotationElement(annotation); |
| 6065 } | 6252 } |
| 6066 return null; | 6253 return null; |
| 6067 } | 6254 } |
| 6068 | 6255 |
| 6256 @override |
| 6069 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 6257 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 6070 ClassElement enclosingClass = _resolver.enclosingClass; | 6258 ClassElement enclosingClass = _resolver.enclosingClass; |
| 6071 if (enclosingClass == null) { | 6259 if (enclosingClass == null) { |
| 6072 // TODO(brianwilkerson) Report this error. | 6260 // TODO(brianwilkerson) Report this error. |
| 6073 return null; | 6261 return null; |
| 6074 } | 6262 } |
| 6075 InterfaceType superType = enclosingClass.supertype; | 6263 InterfaceType superType = enclosingClass.supertype; |
| 6076 if (superType == null) { | 6264 if (superType == null) { |
| 6077 // TODO(brianwilkerson) Report this error. | 6265 // TODO(brianwilkerson) Report this error. |
| 6078 return null; | 6266 return null; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6097 } | 6285 } |
| 6098 node.staticElement = element; | 6286 node.staticElement = element; |
| 6099 ArgumentList argumentList = node.argumentList; | 6287 ArgumentList argumentList = node.argumentList; |
| 6100 List<ParameterElement> parameters = _resolveArgumentsToFunction(isInConstCon
structor, argumentList, element); | 6288 List<ParameterElement> parameters = _resolveArgumentsToFunction(isInConstCon
structor, argumentList, element); |
| 6101 if (parameters != null) { | 6289 if (parameters != null) { |
| 6102 argumentList.correspondingStaticParameters = parameters; | 6290 argumentList.correspondingStaticParameters = parameters; |
| 6103 } | 6291 } |
| 6104 return null; | 6292 return null; |
| 6105 } | 6293 } |
| 6106 | 6294 |
| 6295 @override |
| 6107 Object visitSuperExpression(SuperExpression node) { | 6296 Object visitSuperExpression(SuperExpression node) { |
| 6108 if (!_isSuperInValidContext(node)) { | 6297 if (!_isSuperInValidContext(node)) { |
| 6109 _resolver.reportErrorForNode(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT
, node, []); | 6298 _resolver.reportErrorForNode(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT
, node, []); |
| 6110 } | 6299 } |
| 6111 return super.visitSuperExpression(node); | 6300 return super.visitSuperExpression(node); |
| 6112 } | 6301 } |
| 6113 | 6302 |
| 6303 @override |
| 6114 Object visitTypeParameter(TypeParameter node) { | 6304 Object visitTypeParameter(TypeParameter node) { |
| 6115 _setMetadata(node.element, node); | 6305 _setMetadata(node.element, node); |
| 6116 return null; | 6306 return null; |
| 6117 } | 6307 } |
| 6118 | 6308 |
| 6309 @override |
| 6119 Object visitVariableDeclaration(VariableDeclaration node) { | 6310 Object visitVariableDeclaration(VariableDeclaration node) { |
| 6120 _setMetadata(node.element, node); | 6311 _setMetadata(node.element, node); |
| 6121 return null; | 6312 return null; |
| 6122 } | 6313 } |
| 6123 | 6314 |
| 6124 /** | 6315 /** |
| 6125 * Generate annotation elements for each of the annotations in the given node
list and add them to | 6316 * Generate annotation elements for each of the annotations in the given node
list and add them to |
| 6126 * the given list of elements. | 6317 * the given list of elements. |
| 6127 * | 6318 * |
| 6128 * @param annotationList the list of elements to which new elements are to be
added | 6319 * @param annotationList the list of elements to which new elements are to be
added |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 */ | 7670 */ |
| 7480 final String name; | 7671 final String name; |
| 7481 | 7672 |
| 7482 /** | 7673 /** |
| 7483 * Initialize a newly created synthetic identifier to have the given name. | 7674 * Initialize a newly created synthetic identifier to have the given name. |
| 7484 * | 7675 * |
| 7485 * @param name the name of the synthetic identifier | 7676 * @param name the name of the synthetic identifier |
| 7486 */ | 7677 */ |
| 7487 ElementResolver_SyntheticIdentifier(this.name); | 7678 ElementResolver_SyntheticIdentifier(this.name); |
| 7488 | 7679 |
| 7680 @override |
| 7489 accept(AstVisitor visitor) => null; | 7681 accept(AstVisitor visitor) => null; |
| 7490 | 7682 |
| 7683 @override |
| 7491 sc.Token get beginToken => null; | 7684 sc.Token get beginToken => null; |
| 7492 | 7685 |
| 7686 @override |
| 7493 Element get bestElement => null; | 7687 Element get bestElement => null; |
| 7494 | 7688 |
| 7689 @override |
| 7495 sc.Token get endToken => null; | 7690 sc.Token get endToken => null; |
| 7496 | 7691 |
| 7692 @override |
| 7497 int get precedence => 16; | 7693 int get precedence => 16; |
| 7498 | 7694 |
| 7695 @override |
| 7499 Element get propagatedElement => null; | 7696 Element get propagatedElement => null; |
| 7500 | 7697 |
| 7698 @override |
| 7501 Element get staticElement => null; | 7699 Element get staticElement => null; |
| 7502 | 7700 |
| 7701 @override |
| 7503 void visitChildren(AstVisitor visitor) { | 7702 void visitChildren(AstVisitor visitor) { |
| 7504 } | 7703 } |
| 7505 } | 7704 } |
| 7506 | 7705 |
| 7507 /** | 7706 /** |
| 7508 * Instances of the class `IncrementalResolver` resolve the smallest portion of
an AST | 7707 * Instances of the class `IncrementalResolver` resolve the smallest portion of
an AST |
| 7509 * structure that we currently know how to resolve. | 7708 * structure that we currently know how to resolve. |
| 7510 */ | 7709 */ |
| 7511 class IncrementalResolver { | 7710 class IncrementalResolver { |
| 7512 /** | 7711 /** |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8801 * | 9000 * |
| 8802 * @param libraryElement the library element representing this library | 9001 * @param libraryElement the library element representing this library |
| 8803 */ | 9002 */ |
| 8804 void set libraryElement(LibraryElementImpl libraryElement) { | 9003 void set libraryElement(LibraryElementImpl libraryElement) { |
| 8805 this._libraryElement = libraryElement; | 9004 this._libraryElement = libraryElement; |
| 8806 if (_inheritanceManager != null) { | 9005 if (_inheritanceManager != null) { |
| 8807 _inheritanceManager.libraryElement = libraryElement; | 9006 _inheritanceManager.libraryElement = libraryElement; |
| 8808 } | 9007 } |
| 8809 } | 9008 } |
| 8810 | 9009 |
| 9010 @override |
| 8811 String toString() => librarySource.shortName; | 9011 String toString() => librarySource.shortName; |
| 8812 } | 9012 } |
| 8813 | 9013 |
| 8814 /** | 9014 /** |
| 8815 * Instances of the class `LibraryElementBuilder` build an element model for a s
ingle library. | 9015 * Instances of the class `LibraryElementBuilder` build an element model for a s
ingle library. |
| 8816 */ | 9016 */ |
| 8817 class LibraryElementBuilder { | 9017 class LibraryElementBuilder { |
| 8818 /** | 9018 /** |
| 8819 * The analysis context in which the element model will be built. | 9019 * The analysis context in which the element model will be built. |
| 8820 */ | 9020 */ |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10052 | 10252 |
| 10053 /** | 10253 /** |
| 10054 * Return the object keeping track of which elements have had their types prom
oted. | 10254 * Return the object keeping track of which elements have had their types prom
oted. |
| 10055 * | 10255 * |
| 10056 * @return the object keeping track of which elements have had their types pro
moted | 10256 * @return the object keeping track of which elements have had their types pro
moted |
| 10057 */ | 10257 */ |
| 10058 TypePromotionManager get promoteManager => _promoteManager; | 10258 TypePromotionManager get promoteManager => _promoteManager; |
| 10059 | 10259 |
| 10060 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro
xyConditionalAnalysisErrors; | 10260 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro
xyConditionalAnalysisErrors; |
| 10061 | 10261 |
| 10262 @override |
| 10062 Object visitAsExpression(AsExpression node) { | 10263 Object visitAsExpression(AsExpression node) { |
| 10063 super.visitAsExpression(node); | 10264 super.visitAsExpression(node); |
| 10064 overrideExpression(node.expression, node.type.type); | 10265 overrideExpression(node.expression, node.type.type); |
| 10065 return null; | 10266 return null; |
| 10066 } | 10267 } |
| 10067 | 10268 |
| 10269 @override |
| 10068 Object visitAssertStatement(AssertStatement node) { | 10270 Object visitAssertStatement(AssertStatement node) { |
| 10069 super.visitAssertStatement(node); | 10271 super.visitAssertStatement(node); |
| 10070 _propagateTrueState(node.condition); | 10272 _propagateTrueState(node.condition); |
| 10071 return null; | 10273 return null; |
| 10072 } | 10274 } |
| 10073 | 10275 |
| 10276 @override |
| 10074 Object visitBinaryExpression(BinaryExpression node) { | 10277 Object visitBinaryExpression(BinaryExpression node) { |
| 10075 sc.TokenType operatorType = node.operator.type; | 10278 sc.TokenType operatorType = node.operator.type; |
| 10076 Expression leftOperand = node.leftOperand; | 10279 Expression leftOperand = node.leftOperand; |
| 10077 Expression rightOperand = node.rightOperand; | 10280 Expression rightOperand = node.rightOperand; |
| 10078 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { | 10281 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { |
| 10079 safelyVisit(leftOperand); | 10282 safelyVisit(leftOperand); |
| 10080 if (rightOperand != null) { | 10283 if (rightOperand != null) { |
| 10081 try { | 10284 try { |
| 10082 _overrideManager.enterScope(); | 10285 _overrideManager.enterScope(); |
| 10083 _promoteManager.enterScope(); | 10286 _promoteManager.enterScope(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 10107 } | 10310 } |
| 10108 } else { | 10311 } else { |
| 10109 safelyVisit(leftOperand); | 10312 safelyVisit(leftOperand); |
| 10110 safelyVisit(rightOperand); | 10313 safelyVisit(rightOperand); |
| 10111 } | 10314 } |
| 10112 node.accept(_elementResolver); | 10315 node.accept(_elementResolver); |
| 10113 node.accept(_typeAnalyzer); | 10316 node.accept(_typeAnalyzer); |
| 10114 return null; | 10317 return null; |
| 10115 } | 10318 } |
| 10116 | 10319 |
| 10320 @override |
| 10117 Object visitBlockFunctionBody(BlockFunctionBody node) { | 10321 Object visitBlockFunctionBody(BlockFunctionBody node) { |
| 10118 safelyVisit(_commentBeforeFunction); | 10322 safelyVisit(_commentBeforeFunction); |
| 10119 try { | 10323 try { |
| 10120 _overrideManager.enterScope(); | 10324 _overrideManager.enterScope(); |
| 10121 super.visitBlockFunctionBody(node); | 10325 super.visitBlockFunctionBody(node); |
| 10122 } finally { | 10326 } finally { |
| 10123 _overrideManager.exitScope(); | 10327 _overrideManager.exitScope(); |
| 10124 } | 10328 } |
| 10125 return null; | 10329 return null; |
| 10126 } | 10330 } |
| 10127 | 10331 |
| 10332 @override |
| 10128 Object visitBreakStatement(BreakStatement node) { | 10333 Object visitBreakStatement(BreakStatement node) { |
| 10129 // | 10334 // |
| 10130 // We do not visit the label because it needs to be visited in the context o
f the statement. | 10335 // We do not visit the label because it needs to be visited in the context o
f the statement. |
| 10131 // | 10336 // |
| 10132 node.accept(_elementResolver); | 10337 node.accept(_elementResolver); |
| 10133 node.accept(_typeAnalyzer); | 10338 node.accept(_typeAnalyzer); |
| 10134 return null; | 10339 return null; |
| 10135 } | 10340 } |
| 10136 | 10341 |
| 10342 @override |
| 10137 Object visitClassDeclaration(ClassDeclaration node) { | 10343 Object visitClassDeclaration(ClassDeclaration node) { |
| 10138 ClassElement outerType = _enclosingClass; | 10344 ClassElement outerType = _enclosingClass; |
| 10139 try { | 10345 try { |
| 10140 _enclosingClass = node.element; | 10346 _enclosingClass = node.element; |
| 10141 _typeAnalyzer.thisType = _enclosingClass == null ? null : _enclosingClass.
type; | 10347 _typeAnalyzer.thisType = _enclosingClass == null ? null : _enclosingClass.
type; |
| 10142 super.visitClassDeclaration(node); | 10348 super.visitClassDeclaration(node); |
| 10143 } finally { | 10349 } finally { |
| 10144 _typeAnalyzer.thisType = outerType == null ? null : outerType.type; | 10350 _typeAnalyzer.thisType = outerType == null ? null : outerType.type; |
| 10145 _enclosingClass = outerType; | 10351 _enclosingClass = outerType; |
| 10146 } | 10352 } |
| 10147 return null; | 10353 return null; |
| 10148 } | 10354 } |
| 10149 | 10355 |
| 10356 @override |
| 10150 Object visitComment(Comment node) { | 10357 Object visitComment(Comment node) { |
| 10151 if (node.parent is FunctionDeclaration || node.parent is ConstructorDeclarat
ion || node.parent is MethodDeclaration) { | 10358 if (node.parent is FunctionDeclaration || node.parent is ConstructorDeclarat
ion || node.parent is MethodDeclaration) { |
| 10152 if (node != _commentBeforeFunction) { | 10359 if (node != _commentBeforeFunction) { |
| 10153 _commentBeforeFunction = node; | 10360 _commentBeforeFunction = node; |
| 10154 return null; | 10361 return null; |
| 10155 } | 10362 } |
| 10156 } | 10363 } |
| 10157 super.visitComment(node); | 10364 super.visitComment(node); |
| 10158 _commentBeforeFunction = null; | 10365 _commentBeforeFunction = null; |
| 10159 return null; | 10366 return null; |
| 10160 } | 10367 } |
| 10161 | 10368 |
| 10369 @override |
| 10162 Object visitCommentReference(CommentReference node) { | 10370 Object visitCommentReference(CommentReference node) { |
| 10163 // | 10371 // |
| 10164 // We do not visit the identifier because it needs to be visited in the cont
ext of the reference. | 10372 // We do not visit the identifier because it needs to be visited in the cont
ext of the reference. |
| 10165 // | 10373 // |
| 10166 node.accept(_elementResolver); | 10374 node.accept(_elementResolver); |
| 10167 node.accept(_typeAnalyzer); | 10375 node.accept(_typeAnalyzer); |
| 10168 return null; | 10376 return null; |
| 10169 } | 10377 } |
| 10170 | 10378 |
| 10379 @override |
| 10171 Object visitCompilationUnit(CompilationUnit node) { | 10380 Object visitCompilationUnit(CompilationUnit node) { |
| 10172 // | 10381 // |
| 10173 // TODO(brianwilkerson) The goal of the code below is to visit the declarati
ons in such an | 10382 // TODO(brianwilkerson) The goal of the code below is to visit the declarati
ons in such an |
| 10174 // order that we can infer type information for top-level variables before w
e visit references | 10383 // order that we can infer type information for top-level variables before w
e visit references |
| 10175 // to them. This is better than making no effort, but still doesn't complete
ly satisfy that | 10384 // to them. This is better than making no effort, but still doesn't complete
ly satisfy that |
| 10176 // goal (consider for example "final var a = b; final var b = 0;"; we'll inf
er a type of 'int' | 10385 // goal (consider for example "final var a = b; final var b = 0;"; we'll inf
er a type of 'int' |
| 10177 // for 'b', but not for 'a' because of the order of the visits). Ideally we
would create a | 10386 // for 'b', but not for 'a' because of the order of the visits). Ideally we
would create a |
| 10178 // dependency graph, but that would require references to be resolved, which
they are not. | 10387 // dependency graph, but that would require references to be resolved, which
they are not. |
| 10179 // | 10388 // |
| 10180 try { | 10389 try { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 10199 } | 10408 } |
| 10200 } | 10409 } |
| 10201 } finally { | 10410 } finally { |
| 10202 _overrideManager.exitScope(); | 10411 _overrideManager.exitScope(); |
| 10203 } | 10412 } |
| 10204 node.accept(_elementResolver); | 10413 node.accept(_elementResolver); |
| 10205 node.accept(_typeAnalyzer); | 10414 node.accept(_typeAnalyzer); |
| 10206 return null; | 10415 return null; |
| 10207 } | 10416 } |
| 10208 | 10417 |
| 10418 @override |
| 10209 Object visitConditionalExpression(ConditionalExpression node) { | 10419 Object visitConditionalExpression(ConditionalExpression node) { |
| 10210 Expression condition = node.condition; | 10420 Expression condition = node.condition; |
| 10211 safelyVisit(condition); | 10421 safelyVisit(condition); |
| 10212 Expression thenExpression = node.thenExpression; | 10422 Expression thenExpression = node.thenExpression; |
| 10213 if (thenExpression != null) { | 10423 if (thenExpression != null) { |
| 10214 try { | 10424 try { |
| 10215 _overrideManager.enterScope(); | 10425 _overrideManager.enterScope(); |
| 10216 _promoteManager.enterScope(); | 10426 _promoteManager.enterScope(); |
| 10217 _propagateTrueState(condition); | 10427 _propagateTrueState(condition); |
| 10218 // Type promotion. | 10428 // Type promotion. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 10243 if (elseIsAbrupt && !thenIsAbrupt) { | 10453 if (elseIsAbrupt && !thenIsAbrupt) { |
| 10244 _propagateTrueState(condition); | 10454 _propagateTrueState(condition); |
| 10245 _propagateState(thenExpression); | 10455 _propagateState(thenExpression); |
| 10246 } else if (thenIsAbrupt && !elseIsAbrupt) { | 10456 } else if (thenIsAbrupt && !elseIsAbrupt) { |
| 10247 _propagateFalseState(condition); | 10457 _propagateFalseState(condition); |
| 10248 _propagateState(elseExpression); | 10458 _propagateState(elseExpression); |
| 10249 } | 10459 } |
| 10250 return null; | 10460 return null; |
| 10251 } | 10461 } |
| 10252 | 10462 |
| 10463 @override |
| 10253 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 10464 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 10254 ExecutableElement outerFunction = _enclosingFunction; | 10465 ExecutableElement outerFunction = _enclosingFunction; |
| 10255 try { | 10466 try { |
| 10256 _enclosingFunction = node.element; | 10467 _enclosingFunction = node.element; |
| 10257 super.visitConstructorDeclaration(node); | 10468 super.visitConstructorDeclaration(node); |
| 10258 } finally { | 10469 } finally { |
| 10259 _enclosingFunction = outerFunction; | 10470 _enclosingFunction = outerFunction; |
| 10260 } | 10471 } |
| 10261 return null; | 10472 return null; |
| 10262 } | 10473 } |
| 10263 | 10474 |
| 10475 @override |
| 10264 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 10476 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 10265 // | 10477 // |
| 10266 // We visit the expression, but do not visit the field name because it needs
to be visited in | 10478 // We visit the expression, but do not visit the field name because it needs
to be visited in |
| 10267 // the context of the constructor field initializer node. | 10479 // the context of the constructor field initializer node. |
| 10268 // | 10480 // |
| 10269 safelyVisit(node.expression); | 10481 safelyVisit(node.expression); |
| 10270 node.accept(_elementResolver); | 10482 node.accept(_elementResolver); |
| 10271 node.accept(_typeAnalyzer); | 10483 node.accept(_typeAnalyzer); |
| 10272 return null; | 10484 return null; |
| 10273 } | 10485 } |
| 10274 | 10486 |
| 10487 @override |
| 10275 Object visitConstructorName(ConstructorName node) { | 10488 Object visitConstructorName(ConstructorName node) { |
| 10276 // | 10489 // |
| 10277 // We do not visit either the type name, because it won't be visited anyway,
or the name, | 10490 // We do not visit either the type name, because it won't be visited anyway,
or the name, |
| 10278 // because it needs to be visited in the context of the constructor name. | 10491 // because it needs to be visited in the context of the constructor name. |
| 10279 // | 10492 // |
| 10280 node.accept(_elementResolver); | 10493 node.accept(_elementResolver); |
| 10281 node.accept(_typeAnalyzer); | 10494 node.accept(_typeAnalyzer); |
| 10282 return null; | 10495 return null; |
| 10283 } | 10496 } |
| 10284 | 10497 |
| 10498 @override |
| 10285 Object visitContinueStatement(ContinueStatement node) { | 10499 Object visitContinueStatement(ContinueStatement node) { |
| 10286 // | 10500 // |
| 10287 // We do not visit the label because it needs to be visited in the context o
f the statement. | 10501 // We do not visit the label because it needs to be visited in the context o
f the statement. |
| 10288 // | 10502 // |
| 10289 node.accept(_elementResolver); | 10503 node.accept(_elementResolver); |
| 10290 node.accept(_typeAnalyzer); | 10504 node.accept(_typeAnalyzer); |
| 10291 return null; | 10505 return null; |
| 10292 } | 10506 } |
| 10293 | 10507 |
| 10508 @override |
| 10294 Object visitDoStatement(DoStatement node) { | 10509 Object visitDoStatement(DoStatement node) { |
| 10295 try { | 10510 try { |
| 10296 _overrideManager.enterScope(); | 10511 _overrideManager.enterScope(); |
| 10297 super.visitDoStatement(node); | 10512 super.visitDoStatement(node); |
| 10298 } finally { | 10513 } finally { |
| 10299 _overrideManager.exitScope(); | 10514 _overrideManager.exitScope(); |
| 10300 } | 10515 } |
| 10301 // TODO(brianwilkerson) If the loop can only be exited because the condition
is false, then | 10516 // TODO(brianwilkerson) If the loop can only be exited because the condition
is false, then |
| 10302 // propagateFalseState(node.getCondition()); | 10517 // propagateFalseState(node.getCondition()); |
| 10303 return null; | 10518 return null; |
| 10304 } | 10519 } |
| 10305 | 10520 |
| 10521 @override |
| 10306 Object visitEmptyFunctionBody(EmptyFunctionBody node) { | 10522 Object visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 10307 safelyVisit(_commentBeforeFunction); | 10523 safelyVisit(_commentBeforeFunction); |
| 10308 return super.visitEmptyFunctionBody(node); | 10524 return super.visitEmptyFunctionBody(node); |
| 10309 } | 10525 } |
| 10310 | 10526 |
| 10527 @override |
| 10311 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 10528 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 10312 safelyVisit(_commentBeforeFunction); | 10529 safelyVisit(_commentBeforeFunction); |
| 10313 try { | 10530 try { |
| 10314 _overrideManager.enterScope(); | 10531 _overrideManager.enterScope(); |
| 10315 super.visitExpressionFunctionBody(node); | 10532 super.visitExpressionFunctionBody(node); |
| 10316 } finally { | 10533 } finally { |
| 10317 _overrideManager.exitScope(); | 10534 _overrideManager.exitScope(); |
| 10318 } | 10535 } |
| 10319 return null; | 10536 return null; |
| 10320 } | 10537 } |
| 10321 | 10538 |
| 10539 @override |
| 10322 Object visitFieldDeclaration(FieldDeclaration node) { | 10540 Object visitFieldDeclaration(FieldDeclaration node) { |
| 10323 try { | 10541 try { |
| 10324 _overrideManager.enterScope(); | 10542 _overrideManager.enterScope(); |
| 10325 super.visitFieldDeclaration(node); | 10543 super.visitFieldDeclaration(node); |
| 10326 } finally { | 10544 } finally { |
| 10327 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node.
fields); | 10545 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node.
fields); |
| 10328 _overrideManager.exitScope(); | 10546 _overrideManager.exitScope(); |
| 10329 _overrideManager.applyOverrides(overrides); | 10547 _overrideManager.applyOverrides(overrides); |
| 10330 } | 10548 } |
| 10331 return null; | 10549 return null; |
| 10332 } | 10550 } |
| 10333 | 10551 |
| 10552 @override |
| 10334 Object visitForEachStatement(ForEachStatement node) { | 10553 Object visitForEachStatement(ForEachStatement node) { |
| 10335 try { | 10554 try { |
| 10336 _overrideManager.enterScope(); | 10555 _overrideManager.enterScope(); |
| 10337 super.visitForEachStatement(node); | 10556 super.visitForEachStatement(node); |
| 10338 } finally { | 10557 } finally { |
| 10339 _overrideManager.exitScope(); | 10558 _overrideManager.exitScope(); |
| 10340 } | 10559 } |
| 10341 return null; | 10560 return null; |
| 10342 } | 10561 } |
| 10343 | 10562 |
| 10563 @override |
| 10344 Object visitForStatement(ForStatement node) { | 10564 Object visitForStatement(ForStatement node) { |
| 10345 try { | 10565 try { |
| 10346 _overrideManager.enterScope(); | 10566 _overrideManager.enterScope(); |
| 10347 super.visitForStatement(node); | 10567 super.visitForStatement(node); |
| 10348 } finally { | 10568 } finally { |
| 10349 _overrideManager.exitScope(); | 10569 _overrideManager.exitScope(); |
| 10350 } | 10570 } |
| 10351 return null; | 10571 return null; |
| 10352 } | 10572 } |
| 10353 | 10573 |
| 10574 @override |
| 10354 Object visitFunctionDeclaration(FunctionDeclaration node) { | 10575 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 10355 ExecutableElement outerFunction = _enclosingFunction; | 10576 ExecutableElement outerFunction = _enclosingFunction; |
| 10356 try { | 10577 try { |
| 10357 SimpleIdentifier functionName = node.name; | 10578 SimpleIdentifier functionName = node.name; |
| 10358 _enclosingFunction = functionName.staticElement as ExecutableElement; | 10579 _enclosingFunction = functionName.staticElement as ExecutableElement; |
| 10359 super.visitFunctionDeclaration(node); | 10580 super.visitFunctionDeclaration(node); |
| 10360 } finally { | 10581 } finally { |
| 10361 _enclosingFunction = outerFunction; | 10582 _enclosingFunction = outerFunction; |
| 10362 } | 10583 } |
| 10363 return null; | 10584 return null; |
| 10364 } | 10585 } |
| 10365 | 10586 |
| 10587 @override |
| 10366 Object visitFunctionExpression(FunctionExpression node) { | 10588 Object visitFunctionExpression(FunctionExpression node) { |
| 10367 ExecutableElement outerFunction = _enclosingFunction; | 10589 ExecutableElement outerFunction = _enclosingFunction; |
| 10368 try { | 10590 try { |
| 10369 _enclosingFunction = node.element; | 10591 _enclosingFunction = node.element; |
| 10370 _overrideManager.enterScope(); | 10592 _overrideManager.enterScope(); |
| 10371 super.visitFunctionExpression(node); | 10593 super.visitFunctionExpression(node); |
| 10372 } finally { | 10594 } finally { |
| 10373 _overrideManager.exitScope(); | 10595 _overrideManager.exitScope(); |
| 10374 _enclosingFunction = outerFunction; | 10596 _enclosingFunction = outerFunction; |
| 10375 } | 10597 } |
| 10376 return null; | 10598 return null; |
| 10377 } | 10599 } |
| 10378 | 10600 |
| 10601 @override |
| 10379 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 10602 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 10380 safelyVisit(node.function); | 10603 safelyVisit(node.function); |
| 10381 node.accept(_elementResolver); | 10604 node.accept(_elementResolver); |
| 10382 _inferFunctionExpressionsParametersTypes(node.argumentList); | 10605 _inferFunctionExpressionsParametersTypes(node.argumentList); |
| 10383 safelyVisit(node.argumentList); | 10606 safelyVisit(node.argumentList); |
| 10384 node.accept(_typeAnalyzer); | 10607 node.accept(_typeAnalyzer); |
| 10385 return null; | 10608 return null; |
| 10386 } | 10609 } |
| 10387 | 10610 |
| 10611 @override |
| 10388 Object visitHideCombinator(HideCombinator node) => null; | 10612 Object visitHideCombinator(HideCombinator node) => null; |
| 10389 | 10613 |
| 10614 @override |
| 10390 Object visitIfStatement(IfStatement node) { | 10615 Object visitIfStatement(IfStatement node) { |
| 10391 Expression condition = node.condition; | 10616 Expression condition = node.condition; |
| 10392 safelyVisit(condition); | 10617 safelyVisit(condition); |
| 10393 Map<Element, DartType> thenOverrides = null; | 10618 Map<Element, DartType> thenOverrides = null; |
| 10394 Statement thenStatement = node.thenStatement; | 10619 Statement thenStatement = node.thenStatement; |
| 10395 if (thenStatement != null) { | 10620 if (thenStatement != null) { |
| 10396 try { | 10621 try { |
| 10397 _overrideManager.enterScope(); | 10622 _overrideManager.enterScope(); |
| 10398 _promoteManager.enterScope(); | 10623 _promoteManager.enterScope(); |
| 10399 _propagateTrueState(condition); | 10624 _propagateTrueState(condition); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10432 } | 10657 } |
| 10433 } else if (thenIsAbrupt && !elseIsAbrupt) { | 10658 } else if (thenIsAbrupt && !elseIsAbrupt) { |
| 10434 _propagateFalseState(condition); | 10659 _propagateFalseState(condition); |
| 10435 if (elseOverrides != null) { | 10660 if (elseOverrides != null) { |
| 10436 _overrideManager.applyOverrides(elseOverrides); | 10661 _overrideManager.applyOverrides(elseOverrides); |
| 10437 } | 10662 } |
| 10438 } | 10663 } |
| 10439 return null; | 10664 return null; |
| 10440 } | 10665 } |
| 10441 | 10666 |
| 10667 @override |
| 10442 Object visitLabel(Label node) => null; | 10668 Object visitLabel(Label node) => null; |
| 10443 | 10669 |
| 10670 @override |
| 10444 Object visitLibraryIdentifier(LibraryIdentifier node) => null; | 10671 Object visitLibraryIdentifier(LibraryIdentifier node) => null; |
| 10445 | 10672 |
| 10673 @override |
| 10446 Object visitMethodDeclaration(MethodDeclaration node) { | 10674 Object visitMethodDeclaration(MethodDeclaration node) { |
| 10447 ExecutableElement outerFunction = _enclosingFunction; | 10675 ExecutableElement outerFunction = _enclosingFunction; |
| 10448 try { | 10676 try { |
| 10449 _enclosingFunction = node.element; | 10677 _enclosingFunction = node.element; |
| 10450 super.visitMethodDeclaration(node); | 10678 super.visitMethodDeclaration(node); |
| 10451 } finally { | 10679 } finally { |
| 10452 _enclosingFunction = outerFunction; | 10680 _enclosingFunction = outerFunction; |
| 10453 } | 10681 } |
| 10454 return null; | 10682 return null; |
| 10455 } | 10683 } |
| 10456 | 10684 |
| 10685 @override |
| 10457 Object visitMethodInvocation(MethodInvocation node) { | 10686 Object visitMethodInvocation(MethodInvocation node) { |
| 10458 // | 10687 // |
| 10459 // We visit the target and argument list, but do not visit the method name b
ecause it needs to | 10688 // We visit the target and argument list, but do not visit the method name b
ecause it needs to |
| 10460 // be visited in the context of the invocation. | 10689 // be visited in the context of the invocation. |
| 10461 // | 10690 // |
| 10462 safelyVisit(node.target); | 10691 safelyVisit(node.target); |
| 10463 node.accept(_elementResolver); | 10692 node.accept(_elementResolver); |
| 10464 _inferFunctionExpressionsParametersTypes(node.argumentList); | 10693 _inferFunctionExpressionsParametersTypes(node.argumentList); |
| 10465 safelyVisit(node.argumentList); | 10694 safelyVisit(node.argumentList); |
| 10466 node.accept(_typeAnalyzer); | 10695 node.accept(_typeAnalyzer); |
| 10467 return null; | 10696 return null; |
| 10468 } | 10697 } |
| 10469 | 10698 |
| 10699 @override |
| 10470 Object visitNode(AstNode node) { | 10700 Object visitNode(AstNode node) { |
| 10471 node.visitChildren(this); | 10701 node.visitChildren(this); |
| 10472 node.accept(_elementResolver); | 10702 node.accept(_elementResolver); |
| 10473 node.accept(_typeAnalyzer); | 10703 node.accept(_typeAnalyzer); |
| 10474 return null; | 10704 return null; |
| 10475 } | 10705 } |
| 10476 | 10706 |
| 10707 @override |
| 10477 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 10708 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 10478 // | 10709 // |
| 10479 // We visit the prefix, but do not visit the identifier because it needs to
be visited in the | 10710 // We visit the prefix, but do not visit the identifier because it needs to
be visited in the |
| 10480 // context of the prefix. | 10711 // context of the prefix. |
| 10481 // | 10712 // |
| 10482 safelyVisit(node.prefix); | 10713 safelyVisit(node.prefix); |
| 10483 node.accept(_elementResolver); | 10714 node.accept(_elementResolver); |
| 10484 node.accept(_typeAnalyzer); | 10715 node.accept(_typeAnalyzer); |
| 10485 return null; | 10716 return null; |
| 10486 } | 10717 } |
| 10487 | 10718 |
| 10719 @override |
| 10488 Object visitPropertyAccess(PropertyAccess node) { | 10720 Object visitPropertyAccess(PropertyAccess node) { |
| 10489 // | 10721 // |
| 10490 // We visit the target, but do not visit the property name because it needs
to be visited in the | 10722 // We visit the target, but do not visit the property name because it needs
to be visited in the |
| 10491 // context of the property access node. | 10723 // context of the property access node. |
| 10492 // | 10724 // |
| 10493 safelyVisit(node.target); | 10725 safelyVisit(node.target); |
| 10494 node.accept(_elementResolver); | 10726 node.accept(_elementResolver); |
| 10495 node.accept(_typeAnalyzer); | 10727 node.accept(_typeAnalyzer); |
| 10496 return null; | 10728 return null; |
| 10497 } | 10729 } |
| 10498 | 10730 |
| 10731 @override |
| 10499 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 10732 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 10500 // | 10733 // |
| 10501 // We visit the argument list, but do not visit the optional identifier beca
use it needs to be | 10734 // We visit the argument list, but do not visit the optional identifier beca
use it needs to be |
| 10502 // visited in the context of the constructor invocation. | 10735 // visited in the context of the constructor invocation. |
| 10503 // | 10736 // |
| 10504 safelyVisit(node.argumentList); | 10737 safelyVisit(node.argumentList); |
| 10505 node.accept(_elementResolver); | 10738 node.accept(_elementResolver); |
| 10506 node.accept(_typeAnalyzer); | 10739 node.accept(_typeAnalyzer); |
| 10507 return null; | 10740 return null; |
| 10508 } | 10741 } |
| 10509 | 10742 |
| 10743 @override |
| 10510 Object visitShowCombinator(ShowCombinator node) => null; | 10744 Object visitShowCombinator(ShowCombinator node) => null; |
| 10511 | 10745 |
| 10746 @override |
| 10512 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 10747 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 10513 // | 10748 // |
| 10514 // We visit the argument list, but do not visit the optional identifier beca
use it needs to be | 10749 // We visit the argument list, but do not visit the optional identifier beca
use it needs to be |
| 10515 // visited in the context of the constructor invocation. | 10750 // visited in the context of the constructor invocation. |
| 10516 // | 10751 // |
| 10517 safelyVisit(node.argumentList); | 10752 safelyVisit(node.argumentList); |
| 10518 node.accept(_elementResolver); | 10753 node.accept(_elementResolver); |
| 10519 node.accept(_typeAnalyzer); | 10754 node.accept(_typeAnalyzer); |
| 10520 return null; | 10755 return null; |
| 10521 } | 10756 } |
| 10522 | 10757 |
| 10758 @override |
| 10523 Object visitSwitchCase(SwitchCase node) { | 10759 Object visitSwitchCase(SwitchCase node) { |
| 10524 try { | 10760 try { |
| 10525 _overrideManager.enterScope(); | 10761 _overrideManager.enterScope(); |
| 10526 super.visitSwitchCase(node); | 10762 super.visitSwitchCase(node); |
| 10527 } finally { | 10763 } finally { |
| 10528 _overrideManager.exitScope(); | 10764 _overrideManager.exitScope(); |
| 10529 } | 10765 } |
| 10530 return null; | 10766 return null; |
| 10531 } | 10767 } |
| 10532 | 10768 |
| 10769 @override |
| 10533 Object visitSwitchDefault(SwitchDefault node) { | 10770 Object visitSwitchDefault(SwitchDefault node) { |
| 10534 try { | 10771 try { |
| 10535 _overrideManager.enterScope(); | 10772 _overrideManager.enterScope(); |
| 10536 super.visitSwitchDefault(node); | 10773 super.visitSwitchDefault(node); |
| 10537 } finally { | 10774 } finally { |
| 10538 _overrideManager.exitScope(); | 10775 _overrideManager.exitScope(); |
| 10539 } | 10776 } |
| 10540 return null; | 10777 return null; |
| 10541 } | 10778 } |
| 10542 | 10779 |
| 10780 @override |
| 10543 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 10781 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 10544 try { | 10782 try { |
| 10545 _overrideManager.enterScope(); | 10783 _overrideManager.enterScope(); |
| 10546 super.visitTopLevelVariableDeclaration(node); | 10784 super.visitTopLevelVariableDeclaration(node); |
| 10547 } finally { | 10785 } finally { |
| 10548 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node.
variables); | 10786 Map<Element, DartType> overrides = _overrideManager.captureOverrides(node.
variables); |
| 10549 _overrideManager.exitScope(); | 10787 _overrideManager.exitScope(); |
| 10550 _overrideManager.applyOverrides(overrides); | 10788 _overrideManager.applyOverrides(overrides); |
| 10551 } | 10789 } |
| 10552 return null; | 10790 return null; |
| 10553 } | 10791 } |
| 10554 | 10792 |
| 10793 @override |
| 10555 Object visitTypeName(TypeName node) => null; | 10794 Object visitTypeName(TypeName node) => null; |
| 10556 | 10795 |
| 10796 @override |
| 10557 Object visitWhileStatement(WhileStatement node) { | 10797 Object visitWhileStatement(WhileStatement node) { |
| 10558 Expression condition = node.condition; | 10798 Expression condition = node.condition; |
| 10559 safelyVisit(condition); | 10799 safelyVisit(condition); |
| 10560 Statement body = node.body; | 10800 Statement body = node.body; |
| 10561 if (body != null) { | 10801 if (body != null) { |
| 10562 try { | 10802 try { |
| 10563 _overrideManager.enterScope(); | 10803 _overrideManager.enterScope(); |
| 10564 _propagateTrueState(condition); | 10804 _propagateTrueState(condition); |
| 10565 visitStatementInScope(body); | 10805 visitStatementInScope(body); |
| 10566 } finally { | 10806 } finally { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10737 * | 10977 * |
| 10738 * @param enclosingElement the enclosing element | 10978 * @param enclosingElement the enclosing element |
| 10739 * @param errorCode the error code of the error to be reported | 10979 * @param errorCode the error code of the error to be reported |
| 10740 * @param token the token specifying the location of the error | 10980 * @param token the token specifying the location of the error |
| 10741 * @param arguments the arguments to the error, used to compose the error mess
age | 10981 * @param arguments the arguments to the error, used to compose the error mess
age |
| 10742 */ | 10982 */ |
| 10743 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC
ode errorCode, sc.Token token, List<Object> arguments) { | 10983 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC
ode errorCode, sc.Token token, List<Object> arguments) { |
| 10744 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos
ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode
, arguments))); | 10984 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos
ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode
, arguments))); |
| 10745 } | 10985 } |
| 10746 | 10986 |
| 10987 @override |
| 10747 void visitForEachStatementInScope(ForEachStatement node) { | 10988 void visitForEachStatementInScope(ForEachStatement node) { |
| 10748 // | 10989 // |
| 10749 // We visit the iterator before the loop variable because the loop variable
cannot be in scope | 10990 // We visit the iterator before the loop variable because the loop variable
cannot be in scope |
| 10750 // while visiting the iterator. | 10991 // while visiting the iterator. |
| 10751 // | 10992 // |
| 10752 Expression iterator = node.iterator; | 10993 Expression iterator = node.iterator; |
| 10753 safelyVisit(iterator); | 10994 safelyVisit(iterator); |
| 10754 DeclaredIdentifier loopVariable = node.loopVariable; | 10995 DeclaredIdentifier loopVariable = node.loopVariable; |
| 10755 SimpleIdentifier identifier = node.identifier; | 10996 SimpleIdentifier identifier = node.identifier; |
| 10756 safelyVisit(loopVariable); | 10997 safelyVisit(loopVariable); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 10776 } | 11017 } |
| 10777 visitStatementInScope(body); | 11018 visitStatementInScope(body); |
| 10778 } finally { | 11019 } finally { |
| 10779 _overrideManager.exitScope(); | 11020 _overrideManager.exitScope(); |
| 10780 } | 11021 } |
| 10781 } | 11022 } |
| 10782 node.accept(_elementResolver); | 11023 node.accept(_elementResolver); |
| 10783 node.accept(_typeAnalyzer); | 11024 node.accept(_typeAnalyzer); |
| 10784 } | 11025 } |
| 10785 | 11026 |
| 11027 @override |
| 10786 void visitForStatementInScope(ForStatement node) { | 11028 void visitForStatementInScope(ForStatement node) { |
| 10787 safelyVisit(node.variables); | 11029 safelyVisit(node.variables); |
| 10788 safelyVisit(node.initialization); | 11030 safelyVisit(node.initialization); |
| 10789 safelyVisit(node.condition); | 11031 safelyVisit(node.condition); |
| 10790 _overrideManager.enterScope(); | 11032 _overrideManager.enterScope(); |
| 10791 try { | 11033 try { |
| 10792 _propagateTrueState(node.condition); | 11034 _propagateTrueState(node.condition); |
| 10793 visitStatementInScope(node.body); | 11035 visitStatementInScope(node.body); |
| 10794 node.updaters.accept(this); | 11036 node.updaters.accept(this); |
| 10795 } finally { | 11037 } finally { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11158 | 11400 |
| 11159 class RecursiveAstVisitor_ResolverVisitor_isVariableAccessedInClosure extends Re
cursiveAstVisitor<Object> { | 11401 class RecursiveAstVisitor_ResolverVisitor_isVariableAccessedInClosure extends Re
cursiveAstVisitor<Object> { |
| 11160 List<bool> result; | 11402 List<bool> result; |
| 11161 | 11403 |
| 11162 Element variable; | 11404 Element variable; |
| 11163 | 11405 |
| 11164 RecursiveAstVisitor_ResolverVisitor_isVariableAccessedInClosure(this.result, t
his.variable) : super(); | 11406 RecursiveAstVisitor_ResolverVisitor_isVariableAccessedInClosure(this.result, t
his.variable) : super(); |
| 11165 | 11407 |
| 11166 bool _inClosure = false; | 11408 bool _inClosure = false; |
| 11167 | 11409 |
| 11410 @override |
| 11168 Object visitFunctionExpression(FunctionExpression node) { | 11411 Object visitFunctionExpression(FunctionExpression node) { |
| 11169 bool inClosure = this._inClosure; | 11412 bool inClosure = this._inClosure; |
| 11170 try { | 11413 try { |
| 11171 this._inClosure = true; | 11414 this._inClosure = true; |
| 11172 return super.visitFunctionExpression(node); | 11415 return super.visitFunctionExpression(node); |
| 11173 } finally { | 11416 } finally { |
| 11174 this._inClosure = inClosure; | 11417 this._inClosure = inClosure; |
| 11175 } | 11418 } |
| 11176 } | 11419 } |
| 11177 | 11420 |
| 11421 @override |
| 11178 Object visitSimpleIdentifier(SimpleIdentifier node) { | 11422 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 11179 if (result[0]) { | 11423 if (result[0]) { |
| 11180 return null; | 11424 return null; |
| 11181 } | 11425 } |
| 11182 if (_inClosure && identical(node.staticElement, variable)) { | 11426 if (_inClosure && identical(node.staticElement, variable)) { |
| 11183 result[0] = javaBooleanOr(result[0], true); | 11427 result[0] = javaBooleanOr(result[0], true); |
| 11184 } | 11428 } |
| 11185 return null; | 11429 return null; |
| 11186 } | 11430 } |
| 11187 } | 11431 } |
| 11188 | 11432 |
| 11189 class RecursiveAstVisitor_ResolverVisitor_isVariablePotentiallyMutatedIn extends
RecursiveAstVisitor<Object> { | 11433 class RecursiveAstVisitor_ResolverVisitor_isVariablePotentiallyMutatedIn extends
RecursiveAstVisitor<Object> { |
| 11190 List<bool> result; | 11434 List<bool> result; |
| 11191 | 11435 |
| 11192 Element variable; | 11436 Element variable; |
| 11193 | 11437 |
| 11194 RecursiveAstVisitor_ResolverVisitor_isVariablePotentiallyMutatedIn(this.result
, this.variable) : super(); | 11438 RecursiveAstVisitor_ResolverVisitor_isVariablePotentiallyMutatedIn(this.result
, this.variable) : super(); |
| 11195 | 11439 |
| 11440 @override |
| 11196 Object visitSimpleIdentifier(SimpleIdentifier node) { | 11441 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 11197 if (result[0]) { | 11442 if (result[0]) { |
| 11198 return null; | 11443 return null; |
| 11199 } | 11444 } |
| 11200 if (identical(node.staticElement, variable)) { | 11445 if (identical(node.staticElement, variable)) { |
| 11201 if (node.inSetterContext()) { | 11446 if (node.inSetterContext()) { |
| 11202 result[0] = javaBooleanOr(result[0], true); | 11447 result[0] = javaBooleanOr(result[0], true); |
| 11203 } | 11448 } |
| 11204 } | 11449 } |
| 11205 return null; | 11450 return null; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11319 | 11564 |
| 11320 /** | 11565 /** |
| 11321 * Report an error with the given analysis error. | 11566 * Report an error with the given analysis error. |
| 11322 * | 11567 * |
| 11323 * @param errorCode analysis error | 11568 * @param errorCode analysis error |
| 11324 */ | 11569 */ |
| 11325 void reportError(AnalysisError analysisError) { | 11570 void reportError(AnalysisError analysisError) { |
| 11326 _errorListener.onError(analysisError); | 11571 _errorListener.onError(analysisError); |
| 11327 } | 11572 } |
| 11328 | 11573 |
| 11574 @override |
| 11329 Object visitBlock(Block node) { | 11575 Object visitBlock(Block node) { |
| 11330 Scope outerScope = _nameScope; | 11576 Scope outerScope = _nameScope; |
| 11331 try { | 11577 try { |
| 11332 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); | 11578 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); |
| 11333 _hideNamesDefinedInBlock(enclosedScope, node); | 11579 _hideNamesDefinedInBlock(enclosedScope, node); |
| 11334 _nameScope = enclosedScope; | 11580 _nameScope = enclosedScope; |
| 11335 super.visitBlock(node); | 11581 super.visitBlock(node); |
| 11336 } finally { | 11582 } finally { |
| 11337 _nameScope = outerScope; | 11583 _nameScope = outerScope; |
| 11338 } | 11584 } |
| 11339 return null; | 11585 return null; |
| 11340 } | 11586 } |
| 11341 | 11587 |
| 11588 @override |
| 11342 Object visitCatchClause(CatchClause node) { | 11589 Object visitCatchClause(CatchClause node) { |
| 11343 SimpleIdentifier exception = node.exceptionParameter; | 11590 SimpleIdentifier exception = node.exceptionParameter; |
| 11344 if (exception != null) { | 11591 if (exception != null) { |
| 11345 Scope outerScope = _nameScope; | 11592 Scope outerScope = _nameScope; |
| 11346 try { | 11593 try { |
| 11347 _nameScope = new EnclosedScope(_nameScope); | 11594 _nameScope = new EnclosedScope(_nameScope); |
| 11348 _nameScope.define(exception.staticElement); | 11595 _nameScope.define(exception.staticElement); |
| 11349 SimpleIdentifier stackTrace = node.stackTraceParameter; | 11596 SimpleIdentifier stackTrace = node.stackTraceParameter; |
| 11350 if (stackTrace != null) { | 11597 if (stackTrace != null) { |
| 11351 _nameScope.define(stackTrace.staticElement); | 11598 _nameScope.define(stackTrace.staticElement); |
| 11352 } | 11599 } |
| 11353 super.visitCatchClause(node); | 11600 super.visitCatchClause(node); |
| 11354 } finally { | 11601 } finally { |
| 11355 _nameScope = outerScope; | 11602 _nameScope = outerScope; |
| 11356 } | 11603 } |
| 11357 } else { | 11604 } else { |
| 11358 super.visitCatchClause(node); | 11605 super.visitCatchClause(node); |
| 11359 } | 11606 } |
| 11360 return null; | 11607 return null; |
| 11361 } | 11608 } |
| 11362 | 11609 |
| 11610 @override |
| 11363 Object visitClassDeclaration(ClassDeclaration node) { | 11611 Object visitClassDeclaration(ClassDeclaration node) { |
| 11364 Scope outerScope = _nameScope; | 11612 Scope outerScope = _nameScope; |
| 11365 try { | 11613 try { |
| 11366 _nameScope = new ClassScope(_nameScope, node.element); | 11614 _nameScope = new ClassScope(_nameScope, node.element); |
| 11367 visitClassDeclarationInScope(node); | 11615 visitClassDeclarationInScope(node); |
| 11368 } finally { | 11616 } finally { |
| 11369 _nameScope = outerScope; | 11617 _nameScope = outerScope; |
| 11370 } | 11618 } |
| 11371 return null; | 11619 return null; |
| 11372 } | 11620 } |
| 11373 | 11621 |
| 11622 @override |
| 11374 Object visitClassTypeAlias(ClassTypeAlias node) { | 11623 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 11375 Scope outerScope = _nameScope; | 11624 Scope outerScope = _nameScope; |
| 11376 try { | 11625 try { |
| 11377 _nameScope = new ClassScope(_nameScope, node.element); | 11626 _nameScope = new ClassScope(_nameScope, node.element); |
| 11378 super.visitClassTypeAlias(node); | 11627 super.visitClassTypeAlias(node); |
| 11379 } finally { | 11628 } finally { |
| 11380 _nameScope = outerScope; | 11629 _nameScope = outerScope; |
| 11381 } | 11630 } |
| 11382 return null; | 11631 return null; |
| 11383 } | 11632 } |
| 11384 | 11633 |
| 11634 @override |
| 11385 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 11635 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 11386 Scope outerScope = _nameScope; | 11636 Scope outerScope = _nameScope; |
| 11387 try { | 11637 try { |
| 11388 _nameScope = new FunctionScope(_nameScope, node.element); | 11638 _nameScope = new FunctionScope(_nameScope, node.element); |
| 11389 super.visitConstructorDeclaration(node); | 11639 super.visitConstructorDeclaration(node); |
| 11390 } finally { | 11640 } finally { |
| 11391 _nameScope = outerScope; | 11641 _nameScope = outerScope; |
| 11392 } | 11642 } |
| 11393 return null; | 11643 return null; |
| 11394 } | 11644 } |
| 11395 | 11645 |
| 11646 @override |
| 11396 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 11647 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 11397 VariableElement element = node.element; | 11648 VariableElement element = node.element; |
| 11398 if (element != null) { | 11649 if (element != null) { |
| 11399 _nameScope.define(element); | 11650 _nameScope.define(element); |
| 11400 } | 11651 } |
| 11401 super.visitDeclaredIdentifier(node); | 11652 super.visitDeclaredIdentifier(node); |
| 11402 return null; | 11653 return null; |
| 11403 } | 11654 } |
| 11404 | 11655 |
| 11656 @override |
| 11405 Object visitDoStatement(DoStatement node) { | 11657 Object visitDoStatement(DoStatement node) { |
| 11406 LabelScope outerLabelScope = _labelScope; | 11658 LabelScope outerLabelScope = _labelScope; |
| 11407 try { | 11659 try { |
| 11408 _labelScope = new LabelScope.con1(_labelScope, false, false); | 11660 _labelScope = new LabelScope.con1(_labelScope, false, false); |
| 11409 visitStatementInScope(node.body); | 11661 visitStatementInScope(node.body); |
| 11410 safelyVisit(node.condition); | 11662 safelyVisit(node.condition); |
| 11411 } finally { | 11663 } finally { |
| 11412 _labelScope = outerLabelScope; | 11664 _labelScope = outerLabelScope; |
| 11413 } | 11665 } |
| 11414 return null; | 11666 return null; |
| 11415 } | 11667 } |
| 11416 | 11668 |
| 11669 @override |
| 11417 Object visitForEachStatement(ForEachStatement node) { | 11670 Object visitForEachStatement(ForEachStatement node) { |
| 11418 Scope outerNameScope = _nameScope; | 11671 Scope outerNameScope = _nameScope; |
| 11419 LabelScope outerLabelScope = _labelScope; | 11672 LabelScope outerLabelScope = _labelScope; |
| 11420 try { | 11673 try { |
| 11421 _nameScope = new EnclosedScope(_nameScope); | 11674 _nameScope = new EnclosedScope(_nameScope); |
| 11422 _labelScope = new LabelScope.con1(outerLabelScope, false, false); | 11675 _labelScope = new LabelScope.con1(outerLabelScope, false, false); |
| 11423 visitForEachStatementInScope(node); | 11676 visitForEachStatementInScope(node); |
| 11424 } finally { | 11677 } finally { |
| 11425 _labelScope = outerLabelScope; | 11678 _labelScope = outerLabelScope; |
| 11426 _nameScope = outerNameScope; | 11679 _nameScope = outerNameScope; |
| 11427 } | 11680 } |
| 11428 return null; | 11681 return null; |
| 11429 } | 11682 } |
| 11430 | 11683 |
| 11684 @override |
| 11431 Object visitFormalParameterList(FormalParameterList node) { | 11685 Object visitFormalParameterList(FormalParameterList node) { |
| 11432 super.visitFormalParameterList(node); | 11686 super.visitFormalParameterList(node); |
| 11433 // We finished resolving function signature, now include formal parameters s
cope. | 11687 // We finished resolving function signature, now include formal parameters s
cope. |
| 11434 if (_nameScope is FunctionScope) { | 11688 if (_nameScope is FunctionScope) { |
| 11435 (_nameScope as FunctionScope).defineParameters(); | 11689 (_nameScope as FunctionScope).defineParameters(); |
| 11436 } | 11690 } |
| 11437 if (_nameScope is FunctionTypeScope) { | 11691 if (_nameScope is FunctionTypeScope) { |
| 11438 (_nameScope as FunctionTypeScope).defineParameters(); | 11692 (_nameScope as FunctionTypeScope).defineParameters(); |
| 11439 } | 11693 } |
| 11440 return null; | 11694 return null; |
| 11441 } | 11695 } |
| 11442 | 11696 |
| 11697 @override |
| 11443 Object visitForStatement(ForStatement node) { | 11698 Object visitForStatement(ForStatement node) { |
| 11444 Scope outerNameScope = _nameScope; | 11699 Scope outerNameScope = _nameScope; |
| 11445 LabelScope outerLabelScope = _labelScope; | 11700 LabelScope outerLabelScope = _labelScope; |
| 11446 try { | 11701 try { |
| 11447 _nameScope = new EnclosedScope(_nameScope); | 11702 _nameScope = new EnclosedScope(_nameScope); |
| 11448 _labelScope = new LabelScope.con1(outerLabelScope, false, false); | 11703 _labelScope = new LabelScope.con1(outerLabelScope, false, false); |
| 11449 visitForStatementInScope(node); | 11704 visitForStatementInScope(node); |
| 11450 } finally { | 11705 } finally { |
| 11451 _labelScope = outerLabelScope; | 11706 _labelScope = outerLabelScope; |
| 11452 _nameScope = outerNameScope; | 11707 _nameScope = outerNameScope; |
| 11453 } | 11708 } |
| 11454 return null; | 11709 return null; |
| 11455 } | 11710 } |
| 11456 | 11711 |
| 11712 @override |
| 11457 Object visitFunctionDeclaration(FunctionDeclaration node) { | 11713 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 11458 ExecutableElement function = node.element; | 11714 ExecutableElement function = node.element; |
| 11459 Scope outerScope = _nameScope; | 11715 Scope outerScope = _nameScope; |
| 11460 try { | 11716 try { |
| 11461 _nameScope = new FunctionScope(_nameScope, function); | 11717 _nameScope = new FunctionScope(_nameScope, function); |
| 11462 super.visitFunctionDeclaration(node); | 11718 super.visitFunctionDeclaration(node); |
| 11463 } finally { | 11719 } finally { |
| 11464 _nameScope = outerScope; | 11720 _nameScope = outerScope; |
| 11465 } | 11721 } |
| 11466 if (function.enclosingElement is! CompilationUnitElement) { | 11722 if (function.enclosingElement is! CompilationUnitElement) { |
| 11467 _nameScope.define(function); | 11723 _nameScope.define(function); |
| 11468 } | 11724 } |
| 11469 return null; | 11725 return null; |
| 11470 } | 11726 } |
| 11471 | 11727 |
| 11728 @override |
| 11472 Object visitFunctionExpression(FunctionExpression node) { | 11729 Object visitFunctionExpression(FunctionExpression node) { |
| 11473 if (node.parent is FunctionDeclaration) { | 11730 if (node.parent is FunctionDeclaration) { |
| 11474 // We have already created a function scope and don't need to do so again. | 11731 // We have already created a function scope and don't need to do so again. |
| 11475 super.visitFunctionExpression(node); | 11732 super.visitFunctionExpression(node); |
| 11476 } else { | 11733 } else { |
| 11477 Scope outerScope = _nameScope; | 11734 Scope outerScope = _nameScope; |
| 11478 try { | 11735 try { |
| 11479 ExecutableElement functionElement = node.element; | 11736 ExecutableElement functionElement = node.element; |
| 11480 if (functionElement == null) { | 11737 if (functionElement == null) { |
| 11481 } else { | 11738 } else { |
| 11482 _nameScope = new FunctionScope(_nameScope, functionElement); | 11739 _nameScope = new FunctionScope(_nameScope, functionElement); |
| 11483 } | 11740 } |
| 11484 super.visitFunctionExpression(node); | 11741 super.visitFunctionExpression(node); |
| 11485 } finally { | 11742 } finally { |
| 11486 _nameScope = outerScope; | 11743 _nameScope = outerScope; |
| 11487 } | 11744 } |
| 11488 } | 11745 } |
| 11489 return null; | 11746 return null; |
| 11490 } | 11747 } |
| 11491 | 11748 |
| 11749 @override |
| 11492 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 11750 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 11493 Scope outerScope = _nameScope; | 11751 Scope outerScope = _nameScope; |
| 11494 try { | 11752 try { |
| 11495 _nameScope = new FunctionTypeScope(_nameScope, node.element); | 11753 _nameScope = new FunctionTypeScope(_nameScope, node.element); |
| 11496 super.visitFunctionTypeAlias(node); | 11754 super.visitFunctionTypeAlias(node); |
| 11497 } finally { | 11755 } finally { |
| 11498 _nameScope = outerScope; | 11756 _nameScope = outerScope; |
| 11499 } | 11757 } |
| 11500 return null; | 11758 return null; |
| 11501 } | 11759 } |
| 11502 | 11760 |
| 11761 @override |
| 11503 Object visitIfStatement(IfStatement node) { | 11762 Object visitIfStatement(IfStatement node) { |
| 11504 safelyVisit(node.condition); | 11763 safelyVisit(node.condition); |
| 11505 visitStatementInScope(node.thenStatement); | 11764 visitStatementInScope(node.thenStatement); |
| 11506 visitStatementInScope(node.elseStatement); | 11765 visitStatementInScope(node.elseStatement); |
| 11507 return null; | 11766 return null; |
| 11508 } | 11767 } |
| 11509 | 11768 |
| 11769 @override |
| 11510 Object visitLabeledStatement(LabeledStatement node) { | 11770 Object visitLabeledStatement(LabeledStatement node) { |
| 11511 LabelScope outerScope = _addScopesFor(node.labels); | 11771 LabelScope outerScope = _addScopesFor(node.labels); |
| 11512 try { | 11772 try { |
| 11513 super.visitLabeledStatement(node); | 11773 super.visitLabeledStatement(node); |
| 11514 } finally { | 11774 } finally { |
| 11515 _labelScope = outerScope; | 11775 _labelScope = outerScope; |
| 11516 } | 11776 } |
| 11517 return null; | 11777 return null; |
| 11518 } | 11778 } |
| 11519 | 11779 |
| 11780 @override |
| 11520 Object visitMethodDeclaration(MethodDeclaration node) { | 11781 Object visitMethodDeclaration(MethodDeclaration node) { |
| 11521 Scope outerScope = _nameScope; | 11782 Scope outerScope = _nameScope; |
| 11522 try { | 11783 try { |
| 11523 _nameScope = new FunctionScope(_nameScope, node.element); | 11784 _nameScope = new FunctionScope(_nameScope, node.element); |
| 11524 super.visitMethodDeclaration(node); | 11785 super.visitMethodDeclaration(node); |
| 11525 } finally { | 11786 } finally { |
| 11526 _nameScope = outerScope; | 11787 _nameScope = outerScope; |
| 11527 } | 11788 } |
| 11528 return null; | 11789 return null; |
| 11529 } | 11790 } |
| 11530 | 11791 |
| 11792 @override |
| 11531 Object visitSwitchCase(SwitchCase node) { | 11793 Object visitSwitchCase(SwitchCase node) { |
| 11532 node.expression.accept(this); | 11794 node.expression.accept(this); |
| 11533 Scope outerNameScope = _nameScope; | 11795 Scope outerNameScope = _nameScope; |
| 11534 try { | 11796 try { |
| 11535 _nameScope = new EnclosedScope(_nameScope); | 11797 _nameScope = new EnclosedScope(_nameScope); |
| 11536 node.statements.accept(this); | 11798 node.statements.accept(this); |
| 11537 } finally { | 11799 } finally { |
| 11538 _nameScope = outerNameScope; | 11800 _nameScope = outerNameScope; |
| 11539 } | 11801 } |
| 11540 return null; | 11802 return null; |
| 11541 } | 11803 } |
| 11542 | 11804 |
| 11805 @override |
| 11543 Object visitSwitchDefault(SwitchDefault node) { | 11806 Object visitSwitchDefault(SwitchDefault node) { |
| 11544 Scope outerNameScope = _nameScope; | 11807 Scope outerNameScope = _nameScope; |
| 11545 try { | 11808 try { |
| 11546 _nameScope = new EnclosedScope(_nameScope); | 11809 _nameScope = new EnclosedScope(_nameScope); |
| 11547 node.statements.accept(this); | 11810 node.statements.accept(this); |
| 11548 } finally { | 11811 } finally { |
| 11549 _nameScope = outerNameScope; | 11812 _nameScope = outerNameScope; |
| 11550 } | 11813 } |
| 11551 return null; | 11814 return null; |
| 11552 } | 11815 } |
| 11553 | 11816 |
| 11817 @override |
| 11554 Object visitSwitchStatement(SwitchStatement node) { | 11818 Object visitSwitchStatement(SwitchStatement node) { |
| 11555 LabelScope outerScope = _labelScope; | 11819 LabelScope outerScope = _labelScope; |
| 11556 try { | 11820 try { |
| 11557 _labelScope = new LabelScope.con1(outerScope, true, false); | 11821 _labelScope = new LabelScope.con1(outerScope, true, false); |
| 11558 for (SwitchMember member in node.members) { | 11822 for (SwitchMember member in node.members) { |
| 11559 for (Label label in member.labels) { | 11823 for (Label label in member.labels) { |
| 11560 SimpleIdentifier labelName = label.label; | 11824 SimpleIdentifier labelName = label.label; |
| 11561 LabelElement labelElement = labelName.staticElement as LabelElement; | 11825 LabelElement labelElement = labelName.staticElement as LabelElement; |
| 11562 _labelScope = new LabelScope.con2(_labelScope, labelName.name, labelEl
ement); | 11826 _labelScope = new LabelScope.con2(_labelScope, labelName.name, labelEl
ement); |
| 11563 } | 11827 } |
| 11564 } | 11828 } |
| 11565 super.visitSwitchStatement(node); | 11829 super.visitSwitchStatement(node); |
| 11566 } finally { | 11830 } finally { |
| 11567 _labelScope = outerScope; | 11831 _labelScope = outerScope; |
| 11568 } | 11832 } |
| 11569 return null; | 11833 return null; |
| 11570 } | 11834 } |
| 11571 | 11835 |
| 11836 @override |
| 11572 Object visitVariableDeclaration(VariableDeclaration node) { | 11837 Object visitVariableDeclaration(VariableDeclaration node) { |
| 11573 super.visitVariableDeclaration(node); | 11838 super.visitVariableDeclaration(node); |
| 11574 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { | 11839 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { |
| 11575 VariableElement element = node.element; | 11840 VariableElement element = node.element; |
| 11576 if (element != null) { | 11841 if (element != null) { |
| 11577 _nameScope.define(element); | 11842 _nameScope.define(element); |
| 11578 } | 11843 } |
| 11579 } | 11844 } |
| 11580 return null; | 11845 return null; |
| 11581 } | 11846 } |
| 11582 | 11847 |
| 11848 @override |
| 11583 Object visitWhileStatement(WhileStatement node) { | 11849 Object visitWhileStatement(WhileStatement node) { |
| 11584 LabelScope outerScope = _labelScope; | 11850 LabelScope outerScope = _labelScope; |
| 11585 try { | 11851 try { |
| 11586 _labelScope = new LabelScope.con1(outerScope, false, false); | 11852 _labelScope = new LabelScope.con1(outerScope, false, false); |
| 11587 safelyVisit(node.condition); | 11853 safelyVisit(node.condition); |
| 11588 visitStatementInScope(node.body); | 11854 visitStatementInScope(node.body); |
| 11589 } finally { | 11855 } finally { |
| 11590 _labelScope = outerScope; | 11856 _labelScope = outerScope; |
| 11591 } | 11857 } |
| 11592 return null; | 11858 return null; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11891 * @param thisType the type representing the class containing the nodes being
analyzed | 12157 * @param thisType the type representing the class containing the nodes being
analyzed |
| 11892 */ | 12158 */ |
| 11893 void set thisType(InterfaceType thisType) { | 12159 void set thisType(InterfaceType thisType) { |
| 11894 this._thisType = thisType; | 12160 this._thisType = thisType; |
| 11895 } | 12161 } |
| 11896 | 12162 |
| 11897 /** | 12163 /** |
| 11898 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is | 12164 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is |
| 11899 * `String`.</blockquote> | 12165 * `String`.</blockquote> |
| 11900 */ | 12166 */ |
| 12167 @override |
| 11901 Object visitAdjacentStrings(AdjacentStrings node) { | 12168 Object visitAdjacentStrings(AdjacentStrings node) { |
| 11902 _recordStaticType(node, _typeProvider.stringType); | 12169 _recordStaticType(node, _typeProvider.stringType); |
| 11903 return null; | 12170 return null; |
| 11904 } | 12171 } |
| 11905 | 12172 |
| 11906 /** | 12173 /** |
| 11907 * The Dart Language Specification, 12.33: <blockquote>The static type of an a
rgument definition | 12174 * The Dart Language Specification, 12.33: <blockquote>The static type of an a
rgument definition |
| 11908 * test is `bool`.</blockquote> | 12175 * test is `bool`.</blockquote> |
| 11909 */ | 12176 */ |
| 12177 @override |
| 11910 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | 12178 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 11911 _recordStaticType(node, _typeProvider.boolType); | 12179 _recordStaticType(node, _typeProvider.boolType); |
| 11912 return null; | 12180 return null; |
| 11913 } | 12181 } |
| 11914 | 12182 |
| 11915 /** | 12183 /** |
| 11916 * The Dart Language Specification, 12.32: <blockquote>... the cast expression
<i>e as T</i> ... | 12184 * The Dart Language Specification, 12.32: <blockquote>... the cast expression
<i>e as T</i> ... |
| 11917 * | 12185 * |
| 11918 * It is a static warning if <i>T</i> does not denote a type available in the
current lexical | 12186 * It is a static warning if <i>T</i> does not denote a type available in the
current lexical |
| 11919 * scope. | 12187 * scope. |
| 11920 * | 12188 * |
| 11921 * The static type of a cast expression <i>e as T</i> is <i>T</i>.</blockquote
> | 12189 * The static type of a cast expression <i>e as T</i> is <i>T</i>.</blockquote
> |
| 11922 */ | 12190 */ |
| 12191 @override |
| 11923 Object visitAsExpression(AsExpression node) { | 12192 Object visitAsExpression(AsExpression node) { |
| 11924 _recordStaticType(node, _getType(node.type)); | 12193 _recordStaticType(node, _getType(node.type)); |
| 11925 return null; | 12194 return null; |
| 11926 } | 12195 } |
| 11927 | 12196 |
| 11928 /** | 12197 /** |
| 11929 * The Dart Language Specification, 12.18: <blockquote>... an assignment <i>a<
/i> of the form <i>v | 12198 * The Dart Language Specification, 12.18: <blockquote>... an assignment <i>a<
/i> of the form <i>v |
| 11930 * = e</i> ... | 12199 * = e</i> ... |
| 11931 * | 12200 * |
| 11932 * It is a static type warning if the static type of <i>e</i> may not be assig
ned to the static | 12201 * It is a static type warning if the static type of <i>e</i> may not be assig
ned to the static |
| (...skipping 24 matching lines...) Expand all Loading... |
| 11957 * | 12226 * |
| 11958 * A compound assignment of the form <i>v op= e</i> is equivalent to <i>v = v
op e</i>. A compound | 12227 * A compound assignment of the form <i>v op= e</i> is equivalent to <i>v = v
op e</i>. A compound |
| 11959 * assignment of the form <i>C.v op= e</i> is equivalent to <i>C.v = C.v op e<
/i>. A compound | 12228 * assignment of the form <i>C.v op= e</i> is equivalent to <i>C.v = C.v op e<
/i>. A compound |
| 11960 * assignment of the form <i>e<sub>1</sub>.v op= e<sub>2</sub></i> is equivale
nt to <i>((x) => x.v | 12229 * assignment of the form <i>e<sub>1</sub>.v op= e<sub>2</sub></i> is equivale
nt to <i>((x) => x.v |
| 11961 * = 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 | 12230 * = 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 |
| 11962 * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>[e<
sub>2</sub>] op= | 12231 * <i>e<sub>2</sub></i>. A compound assignment of the form <i>e<sub>1</sub>[e<
sub>2</sub>] op= |
| 11963 * e<sub>3</sub></i> is equivalent to <i>((a, i) => a[i] = a[i] op e<sub>3</su
b>)(e<sub>1</sub>, | 12232 * e<sub>3</sub></i> is equivalent to <i>((a, i) => a[i] = a[i] op e<sub>3</su
b>)(e<sub>1</sub>, |
| 11964 * e<sub>2</sub>)</i> where <i>a</i> and <i>i</i> are a variables that are not
used in | 12233 * e<sub>2</sub>)</i> where <i>a</i> and <i>i</i> are a variables that are not
used in |
| 11965 * <i>e<sub>3</sub></i>.</blockquote> | 12234 * <i>e<sub>3</sub></i>.</blockquote> |
| 11966 */ | 12235 */ |
| 12236 @override |
| 11967 Object visitAssignmentExpression(AssignmentExpression node) { | 12237 Object visitAssignmentExpression(AssignmentExpression node) { |
| 11968 sc.TokenType operator = node.operator.type; | 12238 sc.TokenType operator = node.operator.type; |
| 11969 if (identical(operator, sc.TokenType.EQ)) { | 12239 if (identical(operator, sc.TokenType.EQ)) { |
| 11970 Expression rightHandSide = node.rightHandSide; | 12240 Expression rightHandSide = node.rightHandSide; |
| 11971 DartType staticType = _getStaticType(rightHandSide); | 12241 DartType staticType = _getStaticType(rightHandSide); |
| 11972 _recordStaticType(node, staticType); | 12242 _recordStaticType(node, staticType); |
| 11973 DartType overrideType = staticType; | 12243 DartType overrideType = staticType; |
| 11974 DartType propagatedType = rightHandSide.propagatedType; | 12244 DartType propagatedType = rightHandSide.propagatedType; |
| 11975 if (propagatedType != null) { | 12245 if (propagatedType != null) { |
| 11976 if (propagatedType.isMoreSpecificThan(staticType)) { | 12246 if (propagatedType.isMoreSpecificThan(staticType)) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12024 * <i>e<sub>1</sub>.op(e<sub>2</sub>)</i>. An additive expression of the form
<i>super op | 12294 * <i>e<sub>1</sub>.op(e<sub>2</sub>)</i>. An additive expression of the form
<i>super op |
| 12025 * e<sub>2</sub></i> is equivalent to the method invocation | 12295 * e<sub>2</sub></i> is equivalent to the method invocation |
| 12026 * <i>super.op(e<sub>2</sub>)</i>.</blockquote> | 12296 * <i>super.op(e<sub>2</sub>)</i>.</blockquote> |
| 12027 * | 12297 * |
| 12028 * The Dart Language Specification, 12.26: <blockquote>A multiplicative expres
sion of the form | 12298 * The Dart Language Specification, 12.26: <blockquote>A multiplicative expres
sion of the form |
| 12029 * <i>e<sub>1</sub> op e<sub>2</sub></i> is equivalent to the method invocatio
n | 12299 * <i>e<sub>1</sub> op e<sub>2</sub></i> is equivalent to the method invocatio
n |
| 12030 * <i>e<sub>1</sub>.op(e<sub>2</sub>)</i>. A multiplicative expression of the
form <i>super op | 12300 * <i>e<sub>1</sub>.op(e<sub>2</sub>)</i>. A multiplicative expression of the
form <i>super op |
| 12031 * e<sub>2</sub></i> is equivalent to the method invocation | 12301 * e<sub>2</sub></i> is equivalent to the method invocation |
| 12032 * <i>super.op(e<sub>2</sub>)</i>.</blockquote> | 12302 * <i>super.op(e<sub>2</sub>)</i>.</blockquote> |
| 12033 */ | 12303 */ |
| 12304 @override |
| 12034 Object visitBinaryExpression(BinaryExpression node) { | 12305 Object visitBinaryExpression(BinaryExpression node) { |
| 12035 ExecutableElement staticMethodElement = node.staticElement; | 12306 ExecutableElement staticMethodElement = node.staticElement; |
| 12036 DartType staticType = _computeStaticReturnType(staticMethodElement); | 12307 DartType staticType = _computeStaticReturnType(staticMethodElement); |
| 12037 staticType = _refineBinaryExpressionType(node, staticType); | 12308 staticType = _refineBinaryExpressionType(node, staticType); |
| 12038 _recordStaticType(node, staticType); | 12309 _recordStaticType(node, staticType); |
| 12039 MethodElement propagatedMethodElement = node.propagatedElement; | 12310 MethodElement propagatedMethodElement = node.propagatedElement; |
| 12040 if (propagatedMethodElement != staticMethodElement) { | 12311 if (propagatedMethodElement != staticMethodElement) { |
| 12041 DartType propagatedType = _computeStaticReturnType(propagatedMethodElement
); | 12312 DartType propagatedType = _computeStaticReturnType(propagatedMethodElement
); |
| 12042 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType
)) { | 12313 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType
)) { |
| 12043 _recordPropagatedType(node, propagatedType); | 12314 _recordPropagatedType(node, propagatedType); |
| 12044 } | 12315 } |
| 12045 } | 12316 } |
| 12046 return null; | 12317 return null; |
| 12047 } | 12318 } |
| 12048 | 12319 |
| 12049 /** | 12320 /** |
| 12050 * The Dart Language Specification, 12.4: <blockquote>The static type of a boo
lean literal is | 12321 * The Dart Language Specification, 12.4: <blockquote>The static type of a boo
lean literal is |
| 12051 * bool.</blockquote> | 12322 * bool.</blockquote> |
| 12052 */ | 12323 */ |
| 12324 @override |
| 12053 Object visitBooleanLiteral(BooleanLiteral node) { | 12325 Object visitBooleanLiteral(BooleanLiteral node) { |
| 12054 _recordStaticType(node, _typeProvider.boolType); | 12326 _recordStaticType(node, _typeProvider.boolType); |
| 12055 return null; | 12327 return null; |
| 12056 } | 12328 } |
| 12057 | 12329 |
| 12058 /** | 12330 /** |
| 12059 * The Dart Language Specification, 12.15.2: <blockquote>A cascaded method inv
ocation expression | 12331 * The Dart Language Specification, 12.15.2: <blockquote>A cascaded method inv
ocation expression |
| 12060 * of the form <i>e..suffix</i> is equivalent to the expression <i>(t) {t.suff
ix; return | 12332 * of the form <i>e..suffix</i> is equivalent to the expression <i>(t) {t.suff
ix; return |
| 12061 * t;}(e)</i>.</blockquote> | 12333 * t;}(e)</i>.</blockquote> |
| 12062 */ | 12334 */ |
| 12335 @override |
| 12063 Object visitCascadeExpression(CascadeExpression node) { | 12336 Object visitCascadeExpression(CascadeExpression node) { |
| 12064 _recordStaticType(node, _getStaticType(node.target)); | 12337 _recordStaticType(node, _getStaticType(node.target)); |
| 12065 _recordPropagatedType(node, node.target.propagatedType); | 12338 _recordPropagatedType(node, node.target.propagatedType); |
| 12066 return null; | 12339 return null; |
| 12067 } | 12340 } |
| 12068 | 12341 |
| 12069 /** | 12342 /** |
| 12070 * The Dart Language Specification, 12.19: <blockquote> ... a conditional expr
ession <i>c</i> of | 12343 * The Dart Language Specification, 12.19: <blockquote> ... a conditional expr
ession <i>c</i> of |
| 12071 * the form <i>e<sub>1</sub> ? e<sub>2</sub> : e<sub>3</sub></i> ... | 12344 * the form <i>e<sub>1</sub> ? e<sub>2</sub> : e<sub>3</sub></i> ... |
| 12072 * | 12345 * |
| 12073 * It is a static type warning if the type of e<sub>1</sub> may not be assigne
d to `bool`. | 12346 * It is a static type warning if the type of e<sub>1</sub> may not be assigne
d to `bool`. |
| 12074 * | 12347 * |
| 12075 * The static type of <i>c</i> is the least upper bound of the static type of
<i>e<sub>2</sub></i> | 12348 * The static type of <i>c</i> is the least upper bound of the static type of
<i>e<sub>2</sub></i> |
| 12076 * and the static type of <i>e<sub>3</sub></i>.</blockquote> | 12349 * and the static type of <i>e<sub>3</sub></i>.</blockquote> |
| 12077 */ | 12350 */ |
| 12351 @override |
| 12078 Object visitConditionalExpression(ConditionalExpression node) { | 12352 Object visitConditionalExpression(ConditionalExpression node) { |
| 12079 DartType staticThenType = _getStaticType(node.thenExpression); | 12353 DartType staticThenType = _getStaticType(node.thenExpression); |
| 12080 DartType staticElseType = _getStaticType(node.elseExpression); | 12354 DartType staticElseType = _getStaticType(node.elseExpression); |
| 12081 if (staticThenType == null) { | 12355 if (staticThenType == null) { |
| 12082 // TODO(brianwilkerson) Determine whether this can still happen. | 12356 // TODO(brianwilkerson) Determine whether this can still happen. |
| 12083 staticThenType = _dynamicType; | 12357 staticThenType = _dynamicType; |
| 12084 } | 12358 } |
| 12085 if (staticElseType == null) { | 12359 if (staticElseType == null) { |
| 12086 // TODO(brianwilkerson) Determine whether this can still happen. | 12360 // TODO(brianwilkerson) Determine whether this can still happen. |
| 12087 staticElseType = _dynamicType; | 12361 staticElseType = _dynamicType; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 12105 _recordPropagatedType(node, propagatedType); | 12379 _recordPropagatedType(node, propagatedType); |
| 12106 } | 12380 } |
| 12107 } | 12381 } |
| 12108 return null; | 12382 return null; |
| 12109 } | 12383 } |
| 12110 | 12384 |
| 12111 /** | 12385 /** |
| 12112 * The Dart Language Specification, 12.3: <blockquote>The static type of a lit
eral double is | 12386 * The Dart Language Specification, 12.3: <blockquote>The static type of a lit
eral double is |
| 12113 * double.</blockquote> | 12387 * double.</blockquote> |
| 12114 */ | 12388 */ |
| 12389 @override |
| 12115 Object visitDoubleLiteral(DoubleLiteral node) { | 12390 Object visitDoubleLiteral(DoubleLiteral node) { |
| 12116 _recordStaticType(node, _typeProvider.doubleType); | 12391 _recordStaticType(node, _typeProvider.doubleType); |
| 12117 return null; | 12392 return null; |
| 12118 } | 12393 } |
| 12119 | 12394 |
| 12395 @override |
| 12120 Object visitFunctionDeclaration(FunctionDeclaration node) { | 12396 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 12121 FunctionExpression function = node.functionExpression; | 12397 FunctionExpression function = node.functionExpression; |
| 12122 ExecutableElementImpl functionElement = node.element as ExecutableElementImp
l; | 12398 ExecutableElementImpl functionElement = node.element as ExecutableElementImp
l; |
| 12123 functionElement.returnType = _computeStaticReturnTypeOfFunctionDeclaration(n
ode); | 12399 functionElement.returnType = _computeStaticReturnTypeOfFunctionDeclaration(n
ode); |
| 12124 _recordPropagatedTypeOfFunction(functionElement, function.body); | 12400 _recordPropagatedTypeOfFunction(functionElement, function.body); |
| 12125 _recordStaticType(function, functionElement.type); | 12401 _recordStaticType(function, functionElement.type); |
| 12126 return null; | 12402 return null; |
| 12127 } | 12403 } |
| 12128 | 12404 |
| 12129 /** | 12405 /** |
| (...skipping 19 matching lines...) Expand all Loading... |
| 12149 * where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is cons
idered to have been | 12425 * where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is cons
idered to have been |
| 12150 * specified as dynamic. | 12426 * specified as dynamic. |
| 12151 * | 12427 * |
| 12152 * The static type of a function literal of the form <i>(T<sub>1</sub> a<sub>1
</sub>, …, | 12428 * The static type of a function literal of the form <i>(T<sub>1</sub> a<sub>1
</sub>, …, |
| 12153 * T<sub>n</sub> a<sub>n</sub>, {T<sub>n+1</sub> x<sub>n+1</sub> : d1, &hellip
;, T<sub>n+k</sub> | 12429 * T<sub>n</sub> a<sub>n</sub>, {T<sub>n+1</sub> x<sub>n+1</sub> : d1, &hellip
;, T<sub>n+k</sub> |
| 12154 * x<sub>n+k</sub> : dk}) {s}</i> is <i>(T<sub>1</sub>, …, T<sub>n</sub
>, {T<sub>n+1</sub> | 12430 * x<sub>n+k</sub> : dk}) {s}</i> is <i>(T<sub>1</sub>, …, T<sub>n</sub
>, {T<sub>n+1</sub> |
| 12155 * x<sub>n+1</sub>, …, T<sub>n+k</sub> x<sub>n+k</sub>}) → dynamic
</i>. In any case | 12431 * x<sub>n+1</sub>, …, T<sub>n+k</sub> x<sub>n+k</sub>}) → dynamic
</i>. In any case |
| 12156 * where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is cons
idered to have been | 12432 * where <i>T<sub>i</sub>, 1 <= i <= n</i>, is not specified, it is cons
idered to have been |
| 12157 * specified as dynamic.</blockquote> | 12433 * specified as dynamic.</blockquote> |
| 12158 */ | 12434 */ |
| 12435 @override |
| 12159 Object visitFunctionExpression(FunctionExpression node) { | 12436 Object visitFunctionExpression(FunctionExpression node) { |
| 12160 if (node.parent is FunctionDeclaration) { | 12437 if (node.parent is FunctionDeclaration) { |
| 12161 // The function type will be resolved and set when we visit the parent nod
e. | 12438 // The function type will be resolved and set when we visit the parent nod
e. |
| 12162 return null; | 12439 return null; |
| 12163 } | 12440 } |
| 12164 ExecutableElementImpl functionElement = node.element as ExecutableElementImp
l; | 12441 ExecutableElementImpl functionElement = node.element as ExecutableElementImp
l; |
| 12165 functionElement.returnType = _computeStaticReturnTypeOfFunctionExpression(no
de); | 12442 functionElement.returnType = _computeStaticReturnTypeOfFunctionExpression(no
de); |
| 12166 _recordPropagatedTypeOfFunction(functionElement, node.body); | 12443 _recordPropagatedTypeOfFunction(functionElement, node.body); |
| 12167 _recordStaticType(node, node.element.type); | 12444 _recordStaticType(node, node.element.type); |
| 12168 return null; | 12445 return null; |
| 12169 } | 12446 } |
| 12170 | 12447 |
| 12171 /** | 12448 /** |
| 12172 * The Dart Language Specification, 12.14.4: <blockquote>A function expression
invocation <i>i</i> | 12449 * The Dart Language Specification, 12.14.4: <blockquote>A function expression
invocation <i>i</i> |
| 12173 * has the form <i>e<sub>f</sub>(a<sub>1</sub>, …, a<sub>n</sub>, x<sub
>n+1</sub>: | 12450 * has the form <i>e<sub>f</sub>(a<sub>1</sub>, …, a<sub>n</sub>, x<sub
>n+1</sub>: |
| 12174 * a<sub>n+1</sub>, …, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>, where <i>
e<sub>f</sub></i> is | 12451 * a<sub>n+1</sub>, …, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>, where <i>
e<sub>f</sub></i> is |
| 12175 * an expression. | 12452 * an expression. |
| 12176 * | 12453 * |
| 12177 * It is a static type warning if the static type <i>F</i> of <i>e<sub>f</sub>
</i> may not be | 12454 * It is a static type warning if the static type <i>F</i> of <i>e<sub>f</sub>
</i> may not be |
| 12178 * assigned to a function type. | 12455 * assigned to a function type. |
| 12179 * | 12456 * |
| 12180 * If <i>F</i> is not a function type, the static type of <i>i</i> is dynamic.
Otherwise the | 12457 * If <i>F</i> is not a function type, the static type of <i>i</i> is dynamic.
Otherwise the |
| 12181 * static type of <i>i</i> is the declared return type of <i>F</i>.</blockquot
e> | 12458 * static type of <i>i</i> is the declared return type of <i>F</i>.</blockquot
e> |
| 12182 */ | 12459 */ |
| 12460 @override |
| 12183 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 12461 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 12184 ExecutableElement staticMethodElement = node.staticElement; | 12462 ExecutableElement staticMethodElement = node.staticElement; |
| 12185 // Record static return type of the static element. | 12463 // Record static return type of the static element. |
| 12186 DartType staticStaticType = _computeStaticReturnType(staticMethodElement); | 12464 DartType staticStaticType = _computeStaticReturnType(staticMethodElement); |
| 12187 _recordStaticType(node, staticStaticType); | 12465 _recordStaticType(node, staticStaticType); |
| 12188 // Record propagated return type of the static element. | 12466 // Record propagated return type of the static element. |
| 12189 DartType staticPropagatedType = _computePropagatedReturnType(staticMethodEle
ment); | 12467 DartType staticPropagatedType = _computePropagatedReturnType(staticMethodEle
ment); |
| 12190 if (staticPropagatedType != null && (staticStaticType == null || staticPropa
gatedType.isMoreSpecificThan(staticStaticType))) { | 12468 if (staticPropagatedType != null && (staticStaticType == null || staticPropa
gatedType.isMoreSpecificThan(staticStaticType))) { |
| 12191 _recordPropagatedType(node, staticPropagatedType); | 12469 _recordPropagatedType(node, staticPropagatedType); |
| 12192 } | 12470 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 12204 } | 12482 } |
| 12205 } | 12483 } |
| 12206 return null; | 12484 return null; |
| 12207 } | 12485 } |
| 12208 | 12486 |
| 12209 /** | 12487 /** |
| 12210 * The Dart Language Specification, 12.29: <blockquote>An assignable expressio
n of the form | 12488 * The Dart Language Specification, 12.29: <blockquote>An assignable expressio
n of the form |
| 12211 * <i>e<sub>1</sub>[e<sub>2</sub>]</i> is evaluated as a method invocation of
the operator method | 12489 * <i>e<sub>1</sub>[e<sub>2</sub>]</i> is evaluated as a method invocation of
the operator method |
| 12212 * <i>[]</i> on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.</bloc
kquote> | 12490 * <i>[]</i> on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.</bloc
kquote> |
| 12213 */ | 12491 */ |
| 12492 @override |
| 12214 Object visitIndexExpression(IndexExpression node) { | 12493 Object visitIndexExpression(IndexExpression node) { |
| 12215 if (node.inSetterContext()) { | 12494 if (node.inSetterContext()) { |
| 12216 ExecutableElement staticMethodElement = node.staticElement; | 12495 ExecutableElement staticMethodElement = node.staticElement; |
| 12217 DartType staticType = _computeArgumentType(staticMethodElement); | 12496 DartType staticType = _computeArgumentType(staticMethodElement); |
| 12218 _recordStaticType(node, staticType); | 12497 _recordStaticType(node, staticType); |
| 12219 MethodElement propagatedMethodElement = node.propagatedElement; | 12498 MethodElement propagatedMethodElement = node.propagatedElement; |
| 12220 if (propagatedMethodElement != staticMethodElement) { | 12499 if (propagatedMethodElement != staticMethodElement) { |
| 12221 DartType propagatedType = _computeArgumentType(propagatedMethodElement); | 12500 DartType propagatedType = _computeArgumentType(propagatedMethodElement); |
| 12222 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { | 12501 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticTy
pe)) { |
| 12223 _recordPropagatedType(node, propagatedType); | 12502 _recordPropagatedType(node, propagatedType); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 12240 | 12519 |
| 12241 /** | 12520 /** |
| 12242 * The Dart Language Specification, 12.11.1: <blockquote>The static type of a
new expression of | 12521 * The Dart Language Specification, 12.11.1: <blockquote>The static type of a
new expression of |
| 12243 * either the form <i>new T.id(a<sub>1</sub>, …, a<sub>n</sub>)</i> or
the form <i>new | 12522 * either the form <i>new T.id(a<sub>1</sub>, …, a<sub>n</sub>)</i> or
the form <i>new |
| 12244 * T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>.</blockquote> | 12523 * T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>.</blockquote> |
| 12245 * | 12524 * |
| 12246 * The Dart Language Specification, 12.11.2: <blockquote>The static type of a
constant object | 12525 * The Dart Language Specification, 12.11.2: <blockquote>The static type of a
constant object |
| 12247 * expression of either the form <i>const T.id(a<sub>1</sub>, …, a<sub>
n</sub>)</i> or the | 12526 * expression of either the form <i>const T.id(a<sub>1</sub>, …, a<sub>
n</sub>)</i> or the |
| 12248 * form <i>const T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>. </
blockquote> | 12527 * form <i>const T(a<sub>1</sub>, …, a<sub>n</sub>)</i> is <i>T</i>. </
blockquote> |
| 12249 */ | 12528 */ |
| 12529 @override |
| 12250 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 12530 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 12251 _recordStaticType(node, node.constructorName.type.type); | 12531 _recordStaticType(node, node.constructorName.type.type); |
| 12252 ConstructorElement element = node.staticElement; | 12532 ConstructorElement element = node.staticElement; |
| 12253 if (element != null && "Element" == element.enclosingElement.name) { | 12533 if (element != null && "Element" == element.enclosingElement.name) { |
| 12254 LibraryElement library = element.library; | 12534 LibraryElement library = element.library; |
| 12255 if (_isHtmlLibrary(library)) { | 12535 if (_isHtmlLibrary(library)) { |
| 12256 String constructorName = element.name; | 12536 String constructorName = element.name; |
| 12257 if ("tag" == constructorName) { | 12537 if ("tag" == constructorName) { |
| 12258 DartType returnType = _getFirstArgumentAsTypeWithMap(library, node.arg
umentList, _HTML_ELEMENT_TO_CLASS_MAP); | 12538 DartType returnType = _getFirstArgumentAsTypeWithMap(library, node.arg
umentList, _HTML_ELEMENT_TO_CLASS_MAP); |
| 12259 if (returnType != null) { | 12539 if (returnType != null) { |
| 12260 _recordPropagatedType(node, returnType); | 12540 _recordPropagatedType(node, returnType); |
| 12261 } | 12541 } |
| 12262 } else { | 12542 } else { |
| 12263 DartType returnType = _getElementNameAsType(library, constructorName,
_HTML_ELEMENT_TO_CLASS_MAP); | 12543 DartType returnType = _getElementNameAsType(library, constructorName,
_HTML_ELEMENT_TO_CLASS_MAP); |
| 12264 if (returnType != null) { | 12544 if (returnType != null) { |
| 12265 _recordPropagatedType(node, returnType); | 12545 _recordPropagatedType(node, returnType); |
| 12266 } | 12546 } |
| 12267 } | 12547 } |
| 12268 } | 12548 } |
| 12269 } | 12549 } |
| 12270 return null; | 12550 return null; |
| 12271 } | 12551 } |
| 12272 | 12552 |
| 12273 /** | 12553 /** |
| 12274 * The Dart Language Specification, 12.3: <blockquote>The static type of an in
teger literal is | 12554 * The Dart Language Specification, 12.3: <blockquote>The static type of an in
teger literal is |
| 12275 * `int`.</blockquote> | 12555 * `int`.</blockquote> |
| 12276 */ | 12556 */ |
| 12557 @override |
| 12277 Object visitIntegerLiteral(IntegerLiteral node) { | 12558 Object visitIntegerLiteral(IntegerLiteral node) { |
| 12278 _recordStaticType(node, _typeProvider.intType); | 12559 _recordStaticType(node, _typeProvider.intType); |
| 12279 return null; | 12560 return null; |
| 12280 } | 12561 } |
| 12281 | 12562 |
| 12282 /** | 12563 /** |
| 12283 * The Dart Language Specification, 12.31: <blockquote>It is a static warning
if <i>T</i> does not | 12564 * The Dart Language Specification, 12.31: <blockquote>It is a static warning
if <i>T</i> does not |
| 12284 * denote a type available in the current lexical scope. | 12565 * denote a type available in the current lexical scope. |
| 12285 * | 12566 * |
| 12286 * The static type of an is-expression is `bool`.</blockquote> | 12567 * The static type of an is-expression is `bool`.</blockquote> |
| 12287 */ | 12568 */ |
| 12569 @override |
| 12288 Object visitIsExpression(IsExpression node) { | 12570 Object visitIsExpression(IsExpression node) { |
| 12289 _recordStaticType(node, _typeProvider.boolType); | 12571 _recordStaticType(node, _typeProvider.boolType); |
| 12290 return null; | 12572 return null; |
| 12291 } | 12573 } |
| 12292 | 12574 |
| 12293 /** | 12575 /** |
| 12294 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis
t literal of the | 12576 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis
t literal of the |
| 12295 * form <i><b>const</b> <E>[e<sub>1</sub>, …, e<sub>n</sub>]</i>
or the form | 12577 * form <i><b>const</b> <E>[e<sub>1</sub>, …, e<sub>n</sub>]</i>
or the form |
| 12296 * <i><E>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is `List<E>`
. The static | 12578 * <i><E>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is `List<E>`
. The static |
| 12297 * type a list literal of the form <i><b>const</b> [e<sub>1</sub>, …, e
<sub>n</sub>]</i> or | 12579 * type a list literal of the form <i><b>const</b> [e<sub>1</sub>, …, e
<sub>n</sub>]</i> or |
| 12298 * the form <i>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is `List<dynami
c>` | 12580 * the form <i>[e<sub>1</sub>, …, e<sub>n</sub>]</i> is `List<dynami
c>` |
| 12299 * .</blockquote> | 12581 * .</blockquote> |
| 12300 */ | 12582 */ |
| 12583 @override |
| 12301 Object visitListLiteral(ListLiteral node) { | 12584 Object visitListLiteral(ListLiteral node) { |
| 12302 DartType staticType = _dynamicType; | 12585 DartType staticType = _dynamicType; |
| 12303 TypeArgumentList typeArguments = node.typeArguments; | 12586 TypeArgumentList typeArguments = node.typeArguments; |
| 12304 if (typeArguments != null) { | 12587 if (typeArguments != null) { |
| 12305 NodeList<TypeName> arguments = typeArguments.arguments; | 12588 NodeList<TypeName> arguments = typeArguments.arguments; |
| 12306 if (arguments != null && arguments.length == 1) { | 12589 if (arguments != null && arguments.length == 1) { |
| 12307 TypeName argumentTypeName = arguments[0]; | 12590 TypeName argumentTypeName = arguments[0]; |
| 12308 DartType argumentType = _getType(argumentTypeName); | 12591 DartType argumentType = _getType(argumentTypeName); |
| 12309 if (argumentType != null) { | 12592 if (argumentType != null) { |
| 12310 staticType = argumentType; | 12593 staticType = argumentType; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 12339 * <i><b>const</b> <String, V> {k<sub>1</sub>:e<sub>1</sub>, …, | 12622 * <i><b>const</b> <String, V> {k<sub>1</sub>:e<sub>1</sub>, …, |
| 12340 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i><String, V> {k<sub>1<
/sub>:e<sub>1</sub>, | 12623 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i><String, V> {k<sub>1<
/sub>:e<sub>1</sub>, |
| 12341 * …, k<sub>n</sub>:e<sub>n</sub>}</i> is `Map<String, V>`. The s
tatic type a | 12624 * …, k<sub>n</sub>:e<sub>n</sub>}</i> is `Map<String, V>`. The s
tatic type a |
| 12342 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell
ip;, | 12625 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell
ip;, |
| 12343 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub
>, …, | 12626 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub
>, …, |
| 12344 * k<sub>n</sub>:e<sub>n</sub>}</i> is `Map<String, dynamic>`. | 12627 * k<sub>n</sub>:e<sub>n</sub>}</i> is `Map<String, dynamic>`. |
| 12345 * | 12628 * |
| 12346 * It is a compile-time error if the first type argument to a map literal is n
ot | 12629 * It is a compile-time error if the first type argument to a map literal is n
ot |
| 12347 * <i>String</i>.</blockquote> | 12630 * <i>String</i>.</blockquote> |
| 12348 */ | 12631 */ |
| 12632 @override |
| 12349 Object visitMapLiteral(MapLiteral node) { | 12633 Object visitMapLiteral(MapLiteral node) { |
| 12350 DartType staticKeyType = _dynamicType; | 12634 DartType staticKeyType = _dynamicType; |
| 12351 DartType staticValueType = _dynamicType; | 12635 DartType staticValueType = _dynamicType; |
| 12352 TypeArgumentList typeArguments = node.typeArguments; | 12636 TypeArgumentList typeArguments = node.typeArguments; |
| 12353 if (typeArguments != null) { | 12637 if (typeArguments != null) { |
| 12354 NodeList<TypeName> arguments = typeArguments.arguments; | 12638 NodeList<TypeName> arguments = typeArguments.arguments; |
| 12355 if (arguments != null && arguments.length == 2) { | 12639 if (arguments != null && arguments.length == 2) { |
| 12356 TypeName entryKeyTypeName = arguments[0]; | 12640 TypeName entryKeyTypeName = arguments[0]; |
| 12357 DartType entryKeyType = _getType(entryKeyTypeName); | 12641 DartType entryKeyType = _getType(entryKeyTypeName); |
| 12358 if (entryKeyType != null) { | 12642 if (entryKeyType != null) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12437 * …, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. | 12721 * …, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. |
| 12438 * | 12722 * |
| 12439 * It is a static type warning if <i>S</i> does not have an accessible instanc
e member named m. If | 12723 * It is a static type warning if <i>S</i> does not have an accessible instanc
e member named m. If |
| 12440 * <i>S.m</i> exists, it is a static warning if the type <i>F</i> of <i>S.m</i
> may not be | 12724 * <i>S.m</i> exists, it is a static warning if the type <i>F</i> of <i>S.m</i
> may not be |
| 12441 * assigned to a function type. | 12725 * assigned to a function type. |
| 12442 * | 12726 * |
| 12443 * If <i>S.m</i> does not exist, or if <i>F</i> is not a function type, the st
atic type of | 12727 * If <i>S.m</i> does not exist, or if <i>F</i> is not a function type, the st
atic type of |
| 12444 * <i>i</i> is dynamic. Otherwise the static type of <i>i</i> is the declared
return type of | 12728 * <i>i</i> is dynamic. Otherwise the static type of <i>i</i> is the declared
return type of |
| 12445 * <i>F</i>.</blockquote> | 12729 * <i>F</i>.</blockquote> |
| 12446 */ | 12730 */ |
| 12731 @override |
| 12447 Object visitMethodInvocation(MethodInvocation node) { | 12732 Object visitMethodInvocation(MethodInvocation node) { |
| 12448 SimpleIdentifier methodNameNode = node.methodName; | 12733 SimpleIdentifier methodNameNode = node.methodName; |
| 12449 Element staticMethodElement = methodNameNode.staticElement; | 12734 Element staticMethodElement = methodNameNode.staticElement; |
| 12450 // Record types of the local variable invoked as a function. | 12735 // Record types of the local variable invoked as a function. |
| 12451 if (staticMethodElement is LocalVariableElement) { | 12736 if (staticMethodElement is LocalVariableElement) { |
| 12452 LocalVariableElement variable = staticMethodElement; | 12737 LocalVariableElement variable = staticMethodElement; |
| 12453 DartType staticType = variable.type; | 12738 DartType staticType = variable.type; |
| 12454 _recordStaticType(methodNameNode, staticType); | 12739 _recordStaticType(methodNameNode, staticType); |
| 12455 DartType propagatedType = _overrideManager.getType(variable); | 12740 DartType propagatedType = _overrideManager.getType(variable); |
| 12456 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType
)) { | 12741 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType
)) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12565 // Record propagated return type of the propagated element. | 12850 // Record propagated return type of the propagated element. |
| 12566 DartType propagatedPropagatedType = _computePropagatedReturnType(propaga
tedElement); | 12851 DartType propagatedPropagatedType = _computePropagatedReturnType(propaga
tedElement); |
| 12567 if (propagatedPropagatedType != null && (staticStaticType == null || pro
pagatedPropagatedType.isMoreSpecificThan(staticStaticType)) && (staticPropagated
Type == null || propagatedPropagatedType.isMoreSpecificThan(staticPropagatedType
)) && (propagatedStaticType == null || propagatedPropagatedType.isMoreSpecificTh
an(propagatedStaticType))) { | 12852 if (propagatedPropagatedType != null && (staticStaticType == null || pro
pagatedPropagatedType.isMoreSpecificThan(staticStaticType)) && (staticPropagated
Type == null || propagatedPropagatedType.isMoreSpecificThan(staticPropagatedType
)) && (propagatedStaticType == null || propagatedPropagatedType.isMoreSpecificTh
an(propagatedStaticType))) { |
| 12568 _recordPropagatedType(node, propagatedPropagatedType); | 12853 _recordPropagatedType(node, propagatedPropagatedType); |
| 12569 } | 12854 } |
| 12570 } | 12855 } |
| 12571 } | 12856 } |
| 12572 return null; | 12857 return null; |
| 12573 } | 12858 } |
| 12574 | 12859 |
| 12860 @override |
| 12575 Object visitNamedExpression(NamedExpression node) { | 12861 Object visitNamedExpression(NamedExpression node) { |
| 12576 Expression expression = node.expression; | 12862 Expression expression = node.expression; |
| 12577 _recordStaticType(node, _getStaticType(expression)); | 12863 _recordStaticType(node, _getStaticType(expression)); |
| 12578 _recordPropagatedType(node, expression.propagatedType); | 12864 _recordPropagatedType(node, expression.propagatedType); |
| 12579 return null; | 12865 return null; |
| 12580 } | 12866 } |
| 12581 | 12867 |
| 12582 /** | 12868 /** |
| 12583 * The Dart Language Specification, 12.2: <blockquote>The static type of `null
` is bottom. | 12869 * The Dart Language Specification, 12.2: <blockquote>The static type of `null
` is bottom. |
| 12584 * </blockquote> | 12870 * </blockquote> |
| 12585 */ | 12871 */ |
| 12872 @override |
| 12586 Object visitNullLiteral(NullLiteral node) { | 12873 Object visitNullLiteral(NullLiteral node) { |
| 12587 _recordStaticType(node, _typeProvider.bottomType); | 12874 _recordStaticType(node, _typeProvider.bottomType); |
| 12588 return null; | 12875 return null; |
| 12589 } | 12876 } |
| 12590 | 12877 |
| 12878 @override |
| 12591 Object visitParenthesizedExpression(ParenthesizedExpression node) { | 12879 Object visitParenthesizedExpression(ParenthesizedExpression node) { |
| 12592 Expression expression = node.expression; | 12880 Expression expression = node.expression; |
| 12593 _recordStaticType(node, _getStaticType(expression)); | 12881 _recordStaticType(node, _getStaticType(expression)); |
| 12594 _recordPropagatedType(node, expression.propagatedType); | 12882 _recordPropagatedType(node, expression.propagatedType); |
| 12595 return null; | 12883 return null; |
| 12596 } | 12884 } |
| 12597 | 12885 |
| 12598 /** | 12886 /** |
| 12599 * The Dart Language Specification, 12.28: <blockquote>A postfix expression of
the form | 12887 * The Dart Language Specification, 12.28: <blockquote>A postfix expression of
the form |
| 12600 * <i>v++</i>, where <i>v</i> is an identifier, is equivalent to <i>(){var r =
v; v = r + 1; | 12888 * <i>v++</i>, where <i>v</i> is an identifier, is equivalent to <i>(){var r =
v; v = r + 1; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 12614 * | 12902 * |
| 12615 * A postfix expression of the form <i>C.v--</i> is equivalent to <i>(){var r
= C.v; C.v = r - 1; | 12903 * A postfix expression of the form <i>C.v--</i> is equivalent to <i>(){var r
= C.v; C.v = r - 1; |
| 12616 * return r}()</i>. | 12904 * return r}()</i>. |
| 12617 * | 12905 * |
| 12618 * A postfix expression of the form <i>e1.v--</i> is equivalent to <i>(x){var
r = x.v; x.v = r - | 12906 * A postfix expression of the form <i>e1.v--</i> is equivalent to <i>(x){var
r = x.v; x.v = r - |
| 12619 * 1; return r}(e1)</i>. | 12907 * 1; return r}(e1)</i>. |
| 12620 * | 12908 * |
| 12621 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i)
{var r = a[i]; a[i] | 12909 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i)
{var r = a[i]; a[i] |
| 12622 * = r - 1; return r}(e1, e2)</i></blockquote> | 12910 * = r - 1; return r}(e1, e2)</i></blockquote> |
| 12623 */ | 12911 */ |
| 12912 @override |
| 12624 Object visitPostfixExpression(PostfixExpression node) { | 12913 Object visitPostfixExpression(PostfixExpression node) { |
| 12625 Expression operand = node.operand; | 12914 Expression operand = node.operand; |
| 12626 DartType staticType = _getStaticType(operand); | 12915 DartType staticType = _getStaticType(operand); |
| 12627 sc.TokenType operator = node.operator.type; | 12916 sc.TokenType operator = node.operator.type; |
| 12628 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, sc.
TokenType.PLUS_PLUS)) { | 12917 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, sc.
TokenType.PLUS_PLUS)) { |
| 12629 DartType intType = _typeProvider.intType; | 12918 DartType intType = _typeProvider.intType; |
| 12630 if (identical(_getStaticType(node.operand), intType)) { | 12919 if (identical(_getStaticType(node.operand), intType)) { |
| 12631 staticType = intType; | 12920 staticType = intType; |
| 12632 } | 12921 } |
| 12633 } | 12922 } |
| 12634 _recordStaticType(node, staticType); | 12923 _recordStaticType(node, staticType); |
| 12635 _recordPropagatedType(node, operand.propagatedType); | 12924 _recordPropagatedType(node, operand.propagatedType); |
| 12636 return null; | 12925 return null; |
| 12637 } | 12926 } |
| 12638 | 12927 |
| 12639 /** | 12928 /** |
| 12640 * See [visitSimpleIdentifier]. | 12929 * See [visitSimpleIdentifier]. |
| 12641 */ | 12930 */ |
| 12931 @override |
| 12642 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 12932 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 12643 SimpleIdentifier prefixedIdentifier = node.identifier; | 12933 SimpleIdentifier prefixedIdentifier = node.identifier; |
| 12644 Element staticElement = prefixedIdentifier.staticElement; | 12934 Element staticElement = prefixedIdentifier.staticElement; |
| 12645 DartType staticType = _dynamicType; | 12935 DartType staticType = _dynamicType; |
| 12646 if (staticElement is ClassElement) { | 12936 if (staticElement is ClassElement) { |
| 12647 if (_isNotTypeLiteral(node)) { | 12937 if (_isNotTypeLiteral(node)) { |
| 12648 staticType = staticElement.type; | 12938 staticType = staticElement.type; |
| 12649 } else { | 12939 } else { |
| 12650 staticType = _typeProvider.typeType; | 12940 staticType = _typeProvider.typeType; |
| 12651 } | 12941 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12698 _recordPropagatedType(node, propagatedType); | 12988 _recordPropagatedType(node, propagatedType); |
| 12699 } | 12989 } |
| 12700 return null; | 12990 return null; |
| 12701 } | 12991 } |
| 12702 | 12992 |
| 12703 /** | 12993 /** |
| 12704 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form | 12994 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form |
| 12705 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the | 12995 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the |
| 12706 * form <i>op super</i> is equivalent to the method invocation <i>super.op()<i
>.</blockquote> | 12996 * form <i>op super</i> is equivalent to the method invocation <i>super.op()<i
>.</blockquote> |
| 12707 */ | 12997 */ |
| 12998 @override |
| 12708 Object visitPrefixExpression(PrefixExpression node) { | 12999 Object visitPrefixExpression(PrefixExpression node) { |
| 12709 sc.TokenType operator = node.operator.type; | 13000 sc.TokenType operator = node.operator.type; |
| 12710 if (identical(operator, sc.TokenType.BANG)) { | 13001 if (identical(operator, sc.TokenType.BANG)) { |
| 12711 _recordStaticType(node, _typeProvider.boolType); | 13002 _recordStaticType(node, _typeProvider.boolType); |
| 12712 } else { | 13003 } else { |
| 12713 // The other cases are equivalent to invoking a method. | 13004 // The other cases are equivalent to invoking a method. |
| 12714 ExecutableElement staticMethodElement = node.staticElement; | 13005 ExecutableElement staticMethodElement = node.staticElement; |
| 12715 DartType staticType = _computeStaticReturnType(staticMethodElement); | 13006 DartType staticType = _computeStaticReturnType(staticMethodElement); |
| 12716 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, s
c.TokenType.PLUS_PLUS)) { | 13007 if (identical(operator, sc.TokenType.MINUS_MINUS) || identical(operator, s
c.TokenType.PLUS_PLUS)) { |
| 12717 DartType intType = _typeProvider.intType; | 13008 DartType intType = _typeProvider.intType; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12765 * <i>i</i>, or if <i>C</i> does not declare, implicitly or explicitly, a gett
er named <i>m</i>. | 13056 * <i>i</i>, or if <i>C</i> does not declare, implicitly or explicitly, a gett
er named <i>m</i>. |
| 12766 * | 13057 * |
| 12767 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic | 13058 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic |
| 12768 * otherwise. | 13059 * otherwise. |
| 12769 * | 13060 * |
| 12770 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an | 13061 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an |
| 12771 * identifier ... | 13062 * identifier ... |
| 12772 * | 13063 * |
| 12773 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> | 13064 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> |
| 12774 */ | 13065 */ |
| 13066 @override |
| 12775 Object visitPropertyAccess(PropertyAccess node) { | 13067 Object visitPropertyAccess(PropertyAccess node) { |
| 12776 SimpleIdentifier propertyName = node.propertyName; | 13068 SimpleIdentifier propertyName = node.propertyName; |
| 12777 Element staticElement = propertyName.staticElement; | 13069 Element staticElement = propertyName.staticElement; |
| 12778 DartType staticType = _dynamicType; | 13070 DartType staticType = _dynamicType; |
| 12779 if (staticElement is MethodElement) { | 13071 if (staticElement is MethodElement) { |
| 12780 staticType = staticElement.type; | 13072 staticType = staticElement.type; |
| 12781 } else if (staticElement is PropertyAccessorElement) { | 13073 } else if (staticElement is PropertyAccessorElement) { |
| 12782 Expression realTarget = node.realTarget; | 13074 Expression realTarget = node.realTarget; |
| 12783 staticType = _getTypeOfProperty(staticElement, realTarget != null ? _getSt
aticType(realTarget) : null); | 13075 staticType = _getTypeOfProperty(staticElement, realTarget != null ? _getSt
aticType(realTarget) : null); |
| 12784 } else { | 13076 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 12798 _recordPropagatedType(propertyName, propagatedType); | 13090 _recordPropagatedType(propertyName, propagatedType); |
| 12799 _recordPropagatedType(node, propagatedType); | 13091 _recordPropagatedType(node, propagatedType); |
| 12800 } | 13092 } |
| 12801 return null; | 13093 return null; |
| 12802 } | 13094 } |
| 12803 | 13095 |
| 12804 /** | 13096 /** |
| 12805 * The Dart Language Specification, 12.9: <blockquote>The static type of a ret
hrow expression is | 13097 * The Dart Language Specification, 12.9: <blockquote>The static type of a ret
hrow expression is |
| 12806 * bottom.</blockquote> | 13098 * bottom.</blockquote> |
| 12807 */ | 13099 */ |
| 13100 @override |
| 12808 Object visitRethrowExpression(RethrowExpression node) { | 13101 Object visitRethrowExpression(RethrowExpression node) { |
| 12809 _recordStaticType(node, _typeProvider.bottomType); | 13102 _recordStaticType(node, _typeProvider.bottomType); |
| 12810 return null; | 13103 return null; |
| 12811 } | 13104 } |
| 12812 | 13105 |
| 12813 /** | 13106 /** |
| 12814 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi
fier expression | 13107 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi
fier expression |
| 12815 * <i>e</i> of the form <i>id</i> proceeds as follows: | 13108 * <i>e</i> of the form <i>id</i> proceeds as follows: |
| 12816 * | 13109 * |
| 12817 * Let <i>d</i> be the innermost declaration in the enclosing lexical scope wh
ose name is | 13110 * Let <i>d</i> be the innermost declaration in the enclosing lexical scope wh
ose name is |
| (...skipping 23 matching lines...) Expand all Loading... |
| 12841 * * If <i>d</i> is the declaration of a static variable or static getter decl
ared in class | 13134 * * If <i>d</i> is the declaration of a static variable or static getter decl
ared in class |
| 12842 * <i>C</i>, then <i>e</i> is equivalent to the getter invocation <i>C.id</i>. | 13135 * <i>C</i>, then <i>e</i> is equivalent to the getter invocation <i>C.id</i>. |
| 12843 * * If <i>d</i> is the declaration of a top level getter, then <i>e</i> is eq
uivalent to the | 13136 * * If <i>d</i> is the declaration of a top level getter, then <i>e</i> is eq
uivalent to the |
| 12844 * getter invocation <i>id</i>. | 13137 * getter invocation <i>id</i>. |
| 12845 * * Otherwise, if <i>e</i> occurs inside a top level or static function (be i
t function, | 13138 * * Otherwise, if <i>e</i> occurs inside a top level or static function (be i
t function, |
| 12846 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError | 13139 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError |
| 12847 * to be thrown. | 13140 * to be thrown. |
| 12848 * * Otherwise <i>e</i> is equivalent to the property extraction <i>this.id</i
>. | 13141 * * Otherwise <i>e</i> is equivalent to the property extraction <i>this.id</i
>. |
| 12849 * </blockquote> | 13142 * </blockquote> |
| 12850 */ | 13143 */ |
| 13144 @override |
| 12851 Object visitSimpleIdentifier(SimpleIdentifier node) { | 13145 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 12852 Element element = node.staticElement; | 13146 Element element = node.staticElement; |
| 12853 DartType staticType = _dynamicType; | 13147 DartType staticType = _dynamicType; |
| 12854 if (element is ClassElement) { | 13148 if (element is ClassElement) { |
| 12855 if (_isNotTypeLiteral(node)) { | 13149 if (_isNotTypeLiteral(node)) { |
| 12856 staticType = element.type; | 13150 staticType = element.type; |
| 12857 } else { | 13151 } else { |
| 12858 staticType = _typeProvider.typeType; | 13152 staticType = _typeProvider.typeType; |
| 12859 } | 13153 } |
| 12860 } else if (element is FunctionTypeAliasElement) { | 13154 } else if (element is FunctionTypeAliasElement) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 12887 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ | 13181 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ |
| 12888 _recordPropagatedType(node, propagatedType); | 13182 _recordPropagatedType(node, propagatedType); |
| 12889 } | 13183 } |
| 12890 return null; | 13184 return null; |
| 12891 } | 13185 } |
| 12892 | 13186 |
| 12893 /** | 13187 /** |
| 12894 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is | 13188 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is |
| 12895 * `String`.</blockquote> | 13189 * `String`.</blockquote> |
| 12896 */ | 13190 */ |
| 13191 @override |
| 12897 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | 13192 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 12898 _recordStaticType(node, _typeProvider.stringType); | 13193 _recordStaticType(node, _typeProvider.stringType); |
| 12899 return null; | 13194 return null; |
| 12900 } | 13195 } |
| 12901 | 13196 |
| 12902 /** | 13197 /** |
| 12903 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is | 13198 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is |
| 12904 * `String`.</blockquote> | 13199 * `String`.</blockquote> |
| 12905 */ | 13200 */ |
| 13201 @override |
| 12906 Object visitStringInterpolation(StringInterpolation node) { | 13202 Object visitStringInterpolation(StringInterpolation node) { |
| 12907 _recordStaticType(node, _typeProvider.stringType); | 13203 _recordStaticType(node, _typeProvider.stringType); |
| 12908 return null; | 13204 return null; |
| 12909 } | 13205 } |
| 12910 | 13206 |
| 13207 @override |
| 12911 Object visitSuperExpression(SuperExpression node) { | 13208 Object visitSuperExpression(SuperExpression node) { |
| 12912 if (_thisType == null) { | 13209 if (_thisType == null) { |
| 12913 // TODO(brianwilkerson) Report this error if it hasn't already been report
ed | 13210 // TODO(brianwilkerson) Report this error if it hasn't already been report
ed |
| 12914 _recordStaticType(node, _dynamicType); | 13211 _recordStaticType(node, _dynamicType); |
| 12915 } else { | 13212 } else { |
| 12916 _recordStaticType(node, _thisType); | 13213 _recordStaticType(node, _thisType); |
| 12917 } | 13214 } |
| 12918 return null; | 13215 return null; |
| 12919 } | 13216 } |
| 12920 | 13217 |
| 13218 @override |
| 12921 Object visitSymbolLiteral(SymbolLiteral node) { | 13219 Object visitSymbolLiteral(SymbolLiteral node) { |
| 12922 _recordStaticType(node, _typeProvider.symbolType); | 13220 _recordStaticType(node, _typeProvider.symbolType); |
| 12923 return null; | 13221 return null; |
| 12924 } | 13222 } |
| 12925 | 13223 |
| 12926 /** | 13224 /** |
| 12927 * The Dart Language Specification, 12.10: <blockquote>The static type of `thi
s` is the | 13225 * The Dart Language Specification, 12.10: <blockquote>The static type of `thi
s` is the |
| 12928 * interface of the immediately enclosing class.</blockquote> | 13226 * interface of the immediately enclosing class.</blockquote> |
| 12929 */ | 13227 */ |
| 13228 @override |
| 12930 Object visitThisExpression(ThisExpression node) { | 13229 Object visitThisExpression(ThisExpression node) { |
| 12931 if (_thisType == null) { | 13230 if (_thisType == null) { |
| 12932 // TODO(brianwilkerson) Report this error if it hasn't already been report
ed | 13231 // TODO(brianwilkerson) Report this error if it hasn't already been report
ed |
| 12933 _recordStaticType(node, _dynamicType); | 13232 _recordStaticType(node, _dynamicType); |
| 12934 } else { | 13233 } else { |
| 12935 _recordStaticType(node, _thisType); | 13234 _recordStaticType(node, _thisType); |
| 12936 } | 13235 } |
| 12937 return null; | 13236 return null; |
| 12938 } | 13237 } |
| 12939 | 13238 |
| 12940 /** | 13239 /** |
| 12941 * The Dart Language Specification, 12.8: <blockquote>The static type of a thr
ow expression is | 13240 * The Dart Language Specification, 12.8: <blockquote>The static type of a thr
ow expression is |
| 12942 * bottom.</blockquote> | 13241 * bottom.</blockquote> |
| 12943 */ | 13242 */ |
| 13243 @override |
| 12944 Object visitThrowExpression(ThrowExpression node) { | 13244 Object visitThrowExpression(ThrowExpression node) { |
| 12945 _recordStaticType(node, _typeProvider.bottomType); | 13245 _recordStaticType(node, _typeProvider.bottomType); |
| 12946 return null; | 13246 return null; |
| 12947 } | 13247 } |
| 12948 | 13248 |
| 13249 @override |
| 12949 Object visitVariableDeclaration(VariableDeclaration node) { | 13250 Object visitVariableDeclaration(VariableDeclaration node) { |
| 12950 Expression initializer = node.initializer; | 13251 Expression initializer = node.initializer; |
| 12951 if (initializer != null) { | 13252 if (initializer != null) { |
| 12952 DartType rightType = initializer.bestType; | 13253 DartType rightType = initializer.bestType; |
| 12953 SimpleIdentifier name = node.name; | 13254 SimpleIdentifier name = node.name; |
| 12954 _recordPropagatedType(name, rightType); | 13255 _recordPropagatedType(name, rightType); |
| 12955 VariableElement element = name.staticElement as VariableElement; | 13256 VariableElement element = name.staticElement as VariableElement; |
| 12956 if (element != null) { | 13257 if (element != null) { |
| 12957 _resolver.overrideVariable(element, rightType); | 13258 _resolver.overrideVariable(element, rightType); |
| 12958 } | 13259 } |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13392 get thisType_J2DAccessor => _thisType; | 13693 get thisType_J2DAccessor => _thisType; |
| 13393 | 13694 |
| 13394 set thisType_J2DAccessor(__v) => _thisType = __v; | 13695 set thisType_J2DAccessor(__v) => _thisType = __v; |
| 13395 } | 13696 } |
| 13396 | 13697 |
| 13397 class GeneralizingAstVisitor_StaticTypeAnalyzer_computePropagatedReturnTypeOfFun
ction extends GeneralizingAstVisitor<Object> { | 13698 class GeneralizingAstVisitor_StaticTypeAnalyzer_computePropagatedReturnTypeOfFun
ction extends GeneralizingAstVisitor<Object> { |
| 13398 List<DartType> result; | 13699 List<DartType> result; |
| 13399 | 13700 |
| 13400 GeneralizingAstVisitor_StaticTypeAnalyzer_computePropagatedReturnTypeOfFunctio
n(this.result) : super(); | 13701 GeneralizingAstVisitor_StaticTypeAnalyzer_computePropagatedReturnTypeOfFunctio
n(this.result) : super(); |
| 13401 | 13702 |
| 13703 @override |
| 13402 Object visitExpression(Expression node) => null; | 13704 Object visitExpression(Expression node) => null; |
| 13403 | 13705 |
| 13706 @override |
| 13404 Object visitReturnStatement(ReturnStatement node) { | 13707 Object visitReturnStatement(ReturnStatement node) { |
| 13405 // prepare this 'return' type | 13708 // prepare this 'return' type |
| 13406 DartType type; | 13709 DartType type; |
| 13407 Expression expression = node.expression; | 13710 Expression expression = node.expression; |
| 13408 if (expression != null) { | 13711 if (expression != null) { |
| 13409 type = expression.bestType; | 13712 type = expression.bestType; |
| 13410 } else { | 13713 } else { |
| 13411 type = BottomTypeImpl.instance; | 13714 type = BottomTypeImpl.instance; |
| 13412 } | 13715 } |
| 13413 // merge types | 13716 // merge types |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14101 | 14404 |
| 14102 /** | 14405 /** |
| 14103 * Initialize a newly created type provider to provide the types defined in th
e given library. | 14406 * Initialize a newly created type provider to provide the types defined in th
e given library. |
| 14104 * | 14407 * |
| 14105 * @param coreLibrary the element representing the core library (dart:core). | 14408 * @param coreLibrary the element representing the core library (dart:core). |
| 14106 */ | 14409 */ |
| 14107 TypeProviderImpl(LibraryElement coreLibrary) { | 14410 TypeProviderImpl(LibraryElement coreLibrary) { |
| 14108 _initializeFrom(coreLibrary); | 14411 _initializeFrom(coreLibrary); |
| 14109 } | 14412 } |
| 14110 | 14413 |
| 14414 @override |
| 14111 InterfaceType get boolType => _boolType; | 14415 InterfaceType get boolType => _boolType; |
| 14112 | 14416 |
| 14417 @override |
| 14113 DartType get bottomType => _bottomType; | 14418 DartType get bottomType => _bottomType; |
| 14114 | 14419 |
| 14420 @override |
| 14115 InterfaceType get deprecatedType => _deprecatedType; | 14421 InterfaceType get deprecatedType => _deprecatedType; |
| 14116 | 14422 |
| 14423 @override |
| 14117 InterfaceType get doubleType => _doubleType; | 14424 InterfaceType get doubleType => _doubleType; |
| 14118 | 14425 |
| 14426 @override |
| 14119 DartType get dynamicType => _dynamicType; | 14427 DartType get dynamicType => _dynamicType; |
| 14120 | 14428 |
| 14429 @override |
| 14121 InterfaceType get functionType => _functionType; | 14430 InterfaceType get functionType => _functionType; |
| 14122 | 14431 |
| 14432 @override |
| 14123 InterfaceType get intType => _intType; | 14433 InterfaceType get intType => _intType; |
| 14124 | 14434 |
| 14435 @override |
| 14125 InterfaceType get listType => _listType; | 14436 InterfaceType get listType => _listType; |
| 14126 | 14437 |
| 14438 @override |
| 14127 InterfaceType get mapType => _mapType; | 14439 InterfaceType get mapType => _mapType; |
| 14128 | 14440 |
| 14441 @override |
| 14129 InterfaceType get nullType => _nullType; | 14442 InterfaceType get nullType => _nullType; |
| 14130 | 14443 |
| 14444 @override |
| 14131 InterfaceType get numType => _numType; | 14445 InterfaceType get numType => _numType; |
| 14132 | 14446 |
| 14447 @override |
| 14133 InterfaceType get objectType => _objectType; | 14448 InterfaceType get objectType => _objectType; |
| 14134 | 14449 |
| 14450 @override |
| 14135 InterfaceType get stackTraceType => _stackTraceType; | 14451 InterfaceType get stackTraceType => _stackTraceType; |
| 14136 | 14452 |
| 14453 @override |
| 14137 InterfaceType get stringType => _stringType; | 14454 InterfaceType get stringType => _stringType; |
| 14138 | 14455 |
| 14456 @override |
| 14139 InterfaceType get symbolType => _symbolType; | 14457 InterfaceType get symbolType => _symbolType; |
| 14140 | 14458 |
| 14459 @override |
| 14141 InterfaceType get typeType => _typeType; | 14460 InterfaceType get typeType => _typeType; |
| 14142 | 14461 |
| 14143 /** | 14462 /** |
| 14144 * Return the type with the given name from the given namespace, or `null` if
there is no | 14463 * Return the type with the given name from the given namespace, or `null` if
there is no |
| 14145 * class with the given name. | 14464 * class with the given name. |
| 14146 * | 14465 * |
| 14147 * @param namespace the namespace in which to search for the given name | 14466 * @param namespace the namespace in which to search for the given name |
| 14148 * @param typeName the name of the type being searched for | 14467 * @param typeName the name of the type being searched for |
| 14149 * @return the type that was found | 14468 * @return the type that was found |
| 14150 */ | 14469 */ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14257 * @param source the source representing the compilation unit containing the n
ode being visited | 14576 * @param source the source representing the compilation unit containing the n
ode being visited |
| 14258 * @param typeProvider the object used to access the types from the core libra
ry | 14577 * @param typeProvider the object used to access the types from the core libra
ry |
| 14259 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | 14578 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited |
| 14260 * @param errorListener the error listener that will be informed of any errors
that are found | 14579 * @param errorListener the error listener that will be informed of any errors
that are found |
| 14261 * during resolution | 14580 * during resolution |
| 14262 */ | 14581 */ |
| 14263 TypeResolverVisitor.con3(LibraryElement definingLibrary, Source source, TypePr
ovider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) : sup
er.con3(definingLibrary, source, typeProvider, nameScope, errorListener) { | 14582 TypeResolverVisitor.con3(LibraryElement definingLibrary, Source source, TypePr
ovider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) : sup
er.con3(definingLibrary, source, typeProvider, nameScope, errorListener) { |
| 14264 _dynamicType = typeProvider.dynamicType; | 14583 _dynamicType = typeProvider.dynamicType; |
| 14265 } | 14584 } |
| 14266 | 14585 |
| 14586 @override |
| 14267 Object visitCatchClause(CatchClause node) { | 14587 Object visitCatchClause(CatchClause node) { |
| 14268 super.visitCatchClause(node); | 14588 super.visitCatchClause(node); |
| 14269 SimpleIdentifier exception = node.exceptionParameter; | 14589 SimpleIdentifier exception = node.exceptionParameter; |
| 14270 if (exception != null) { | 14590 if (exception != null) { |
| 14271 // If an 'on' clause is provided the type of the exception parameter is th
e type in the 'on' | 14591 // If an 'on' clause is provided the type of the exception parameter is th
e type in the 'on' |
| 14272 // clause. Otherwise, the type of the exception parameter is 'Object'. | 14592 // clause. Otherwise, the type of the exception parameter is 'Object'. |
| 14273 TypeName exceptionTypeName = node.exceptionType; | 14593 TypeName exceptionTypeName = node.exceptionType; |
| 14274 DartType exceptionType; | 14594 DartType exceptionType; |
| 14275 if (exceptionTypeName == null) { | 14595 if (exceptionTypeName == null) { |
| 14276 exceptionType = typeProvider.dynamicType; | 14596 exceptionType = typeProvider.dynamicType; |
| 14277 } else { | 14597 } else { |
| 14278 exceptionType = _getType(exceptionTypeName); | 14598 exceptionType = _getType(exceptionTypeName); |
| 14279 } | 14599 } |
| 14280 _recordType(exception, exceptionType); | 14600 _recordType(exception, exceptionType); |
| 14281 Element element = exception.staticElement; | 14601 Element element = exception.staticElement; |
| 14282 if (element is VariableElementImpl) { | 14602 if (element is VariableElementImpl) { |
| 14283 element.type = exceptionType; | 14603 element.type = exceptionType; |
| 14284 } else { | 14604 } else { |
| 14285 } | 14605 } |
| 14286 } | 14606 } |
| 14287 SimpleIdentifier stackTrace = node.stackTraceParameter; | 14607 SimpleIdentifier stackTrace = node.stackTraceParameter; |
| 14288 if (stackTrace != null) { | 14608 if (stackTrace != null) { |
| 14289 _recordType(stackTrace, typeProvider.stackTraceType); | 14609 _recordType(stackTrace, typeProvider.stackTraceType); |
| 14290 } | 14610 } |
| 14291 return null; | 14611 return null; |
| 14292 } | 14612 } |
| 14293 | 14613 |
| 14614 @override |
| 14294 Object visitClassDeclaration(ClassDeclaration node) { | 14615 Object visitClassDeclaration(ClassDeclaration node) { |
| 14295 _hasReferenceToSuper = false; | 14616 _hasReferenceToSuper = false; |
| 14296 super.visitClassDeclaration(node); | 14617 super.visitClassDeclaration(node); |
| 14297 ClassElementImpl classElement = _getClassElement(node.name); | 14618 ClassElementImpl classElement = _getClassElement(node.name); |
| 14298 InterfaceType superclassType = null; | 14619 InterfaceType superclassType = null; |
| 14299 ExtendsClause extendsClause = node.extendsClause; | 14620 ExtendsClause extendsClause = node.extendsClause; |
| 14300 if (extendsClause != null) { | 14621 if (extendsClause != null) { |
| 14301 ErrorCode errorCode = (node.withClause == null ? CompileTimeErrorCode.EXTE
NDS_NON_CLASS : CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS); | 14622 ErrorCode errorCode = (node.withClause == null ? CompileTimeErrorCode.EXTE
NDS_NON_CLASS : CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS); |
| 14302 superclassType = _resolveType(extendsClause.superclass, errorCode, errorCo
de); | 14623 superclassType = _resolveType(extendsClause.superclass, errorCode, errorCo
de); |
| 14303 if (superclassType != typeProvider.objectType) { | 14624 if (superclassType != typeProvider.objectType) { |
| 14304 classElement.validMixin = false; | 14625 classElement.validMixin = false; |
| 14305 } | 14626 } |
| 14306 } | 14627 } |
| 14307 if (classElement != null) { | 14628 if (classElement != null) { |
| 14308 if (superclassType == null) { | 14629 if (superclassType == null) { |
| 14309 InterfaceType objectType = typeProvider.objectType; | 14630 InterfaceType objectType = typeProvider.objectType; |
| 14310 if (classElement.type != objectType) { | 14631 if (classElement.type != objectType) { |
| 14311 superclassType = objectType; | 14632 superclassType = objectType; |
| 14312 } | 14633 } |
| 14313 } | 14634 } |
| 14314 classElement.supertype = superclassType; | 14635 classElement.supertype = superclassType; |
| 14315 classElement.hasReferenceToSuper = _hasReferenceToSuper; | 14636 classElement.hasReferenceToSuper = _hasReferenceToSuper; |
| 14316 } | 14637 } |
| 14317 _resolve(classElement, node.withClause, node.implementsClause); | 14638 _resolve(classElement, node.withClause, node.implementsClause); |
| 14318 return null; | 14639 return null; |
| 14319 } | 14640 } |
| 14320 | 14641 |
| 14642 @override |
| 14321 Object visitClassTypeAlias(ClassTypeAlias node) { | 14643 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 14322 super.visitClassTypeAlias(node); | 14644 super.visitClassTypeAlias(node); |
| 14323 ClassElementImpl classElement = _getClassElement(node.name); | 14645 ClassElementImpl classElement = _getClassElement(node.name); |
| 14324 ErrorCode errorCode = CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS; | 14646 ErrorCode errorCode = CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS; |
| 14325 InterfaceType superclassType = _resolveType(node.superclass, errorCode, erro
rCode); | 14647 InterfaceType superclassType = _resolveType(node.superclass, errorCode, erro
rCode); |
| 14326 if (superclassType == null) { | 14648 if (superclassType == null) { |
| 14327 superclassType = typeProvider.objectType; | 14649 superclassType = typeProvider.objectType; |
| 14328 } | 14650 } |
| 14329 if (classElement != null && superclassType != null) { | 14651 if (classElement != null && superclassType != null) { |
| 14330 classElement.supertype = superclassType; | 14652 classElement.supertype = superclassType; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 14344 } | 14666 } |
| 14345 } | 14667 } |
| 14346 classElement.constructors = new List.from(implicitConstructors); | 14668 classElement.constructors = new List.from(implicitConstructors); |
| 14347 } | 14669 } |
| 14348 } | 14670 } |
| 14349 } | 14671 } |
| 14350 _resolve(classElement, node.withClause, node.implementsClause); | 14672 _resolve(classElement, node.withClause, node.implementsClause); |
| 14351 return null; | 14673 return null; |
| 14352 } | 14674 } |
| 14353 | 14675 |
| 14676 @override |
| 14354 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 14677 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 14355 super.visitConstructorDeclaration(node); | 14678 super.visitConstructorDeclaration(node); |
| 14356 ExecutableElementImpl element = node.element as ExecutableElementImpl; | 14679 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 14357 ClassElement definingClass = element.enclosingElement as ClassElement; | 14680 ClassElement definingClass = element.enclosingElement as ClassElement; |
| 14358 element.returnType = definingClass.type; | 14681 element.returnType = definingClass.type; |
| 14359 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); | 14682 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 14360 type.typeArguments = definingClass.type.typeArguments; | 14683 type.typeArguments = definingClass.type.typeArguments; |
| 14361 element.type = type; | 14684 element.type = type; |
| 14362 return null; | 14685 return null; |
| 14363 } | 14686 } |
| 14364 | 14687 |
| 14688 @override |
| 14365 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 14689 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 14366 super.visitDeclaredIdentifier(node); | 14690 super.visitDeclaredIdentifier(node); |
| 14367 DartType declaredType; | 14691 DartType declaredType; |
| 14368 TypeName typeName = node.type; | 14692 TypeName typeName = node.type; |
| 14369 if (typeName == null) { | 14693 if (typeName == null) { |
| 14370 declaredType = _dynamicType; | 14694 declaredType = _dynamicType; |
| 14371 } else { | 14695 } else { |
| 14372 declaredType = _getType(typeName); | 14696 declaredType = _getType(typeName); |
| 14373 } | 14697 } |
| 14374 LocalVariableElementImpl element = node.element as LocalVariableElementImpl; | 14698 LocalVariableElementImpl element = node.element as LocalVariableElementImpl; |
| 14375 element.type = declaredType; | 14699 element.type = declaredType; |
| 14376 return null; | 14700 return null; |
| 14377 } | 14701 } |
| 14378 | 14702 |
| 14703 @override |
| 14379 Object visitFieldFormalParameter(FieldFormalParameter node) { | 14704 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 14380 super.visitFieldFormalParameter(node); | 14705 super.visitFieldFormalParameter(node); |
| 14381 Element element = node.identifier.staticElement; | 14706 Element element = node.identifier.staticElement; |
| 14382 if (element is ParameterElementImpl) { | 14707 if (element is ParameterElementImpl) { |
| 14383 ParameterElementImpl parameter = element; | 14708 ParameterElementImpl parameter = element; |
| 14384 FormalParameterList parameterList = node.parameters; | 14709 FormalParameterList parameterList = node.parameters; |
| 14385 if (parameterList == null) { | 14710 if (parameterList == null) { |
| 14386 DartType type; | 14711 DartType type; |
| 14387 TypeName typeName = node.type; | 14712 TypeName typeName = node.type; |
| 14388 if (typeName == null) { | 14713 if (typeName == null) { |
| 14389 type = _dynamicType; | 14714 type = _dynamicType; |
| 14390 if (parameter is FieldFormalParameterElement) { | 14715 if (parameter is FieldFormalParameterElement) { |
| 14391 FieldElement fieldElement = (parameter as FieldFormalParameterElemen
t).field; | 14716 FieldElement fieldElement = (parameter as FieldFormalParameterElemen
t).field; |
| 14392 if (fieldElement != null) { | 14717 if (fieldElement != null) { |
| 14393 type = fieldElement.type; | 14718 type = fieldElement.type; |
| 14394 } | 14719 } |
| 14395 } | 14720 } |
| 14396 } else { | 14721 } else { |
| 14397 type = _getType(typeName); | 14722 type = _getType(typeName); |
| 14398 } | 14723 } |
| 14399 parameter.type = type; | 14724 parameter.type = type; |
| 14400 } else { | 14725 } else { |
| 14401 _setFunctionTypedParameterType(parameter, node.type, node.parameters); | 14726 _setFunctionTypedParameterType(parameter, node.type, node.parameters); |
| 14402 } | 14727 } |
| 14403 } else { | 14728 } else { |
| 14404 } | 14729 } |
| 14405 return null; | 14730 return null; |
| 14406 } | 14731 } |
| 14407 | 14732 |
| 14733 @override |
| 14408 Object visitFunctionDeclaration(FunctionDeclaration node) { | 14734 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 14409 super.visitFunctionDeclaration(node); | 14735 super.visitFunctionDeclaration(node); |
| 14410 ExecutableElementImpl element = node.element as ExecutableElementImpl; | 14736 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 14411 element.returnType = _computeReturnType(node.returnType); | 14737 element.returnType = _computeReturnType(node.returnType); |
| 14412 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); | 14738 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 14413 ClassElement definingClass = element.getAncestor((element) => element is Cla
ssElement); | 14739 ClassElement definingClass = element.getAncestor((element) => element is Cla
ssElement); |
| 14414 if (definingClass != null) { | 14740 if (definingClass != null) { |
| 14415 type.typeArguments = definingClass.type.typeArguments; | 14741 type.typeArguments = definingClass.type.typeArguments; |
| 14416 } | 14742 } |
| 14417 element.type = type; | 14743 element.type = type; |
| 14418 return null; | 14744 return null; |
| 14419 } | 14745 } |
| 14420 | 14746 |
| 14747 @override |
| 14421 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 14748 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 14422 super.visitFunctionTypeAlias(node); | 14749 super.visitFunctionTypeAlias(node); |
| 14423 FunctionTypeAliasElementImpl element = node.element as FunctionTypeAliasElem
entImpl; | 14750 FunctionTypeAliasElementImpl element = node.element as FunctionTypeAliasElem
entImpl; |
| 14424 element.returnType = _computeReturnType(node.returnType); | 14751 element.returnType = _computeReturnType(node.returnType); |
| 14425 return null; | 14752 return null; |
| 14426 } | 14753 } |
| 14427 | 14754 |
| 14755 @override |
| 14428 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 14756 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 14429 super.visitFunctionTypedFormalParameter(node); | 14757 super.visitFunctionTypedFormalParameter(node); |
| 14430 Element element = node.identifier.staticElement; | 14758 Element element = node.identifier.staticElement; |
| 14431 if (element is ParameterElementImpl) { | 14759 if (element is ParameterElementImpl) { |
| 14432 _setFunctionTypedParameterType(element, node.returnType, node.parameters); | 14760 _setFunctionTypedParameterType(element, node.returnType, node.parameters); |
| 14433 } else { | 14761 } else { |
| 14434 } | 14762 } |
| 14435 return null; | 14763 return null; |
| 14436 } | 14764 } |
| 14437 | 14765 |
| 14766 @override |
| 14438 Object visitMethodDeclaration(MethodDeclaration node) { | 14767 Object visitMethodDeclaration(MethodDeclaration node) { |
| 14439 super.visitMethodDeclaration(node); | 14768 super.visitMethodDeclaration(node); |
| 14440 ExecutableElementImpl element = node.element as ExecutableElementImpl; | 14769 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
| 14441 element.returnType = _computeReturnType(node.returnType); | 14770 element.returnType = _computeReturnType(node.returnType); |
| 14442 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); | 14771 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
| 14443 ClassElement definingClass = element.getAncestor((element) => element is Cla
ssElement); | 14772 ClassElement definingClass = element.getAncestor((element) => element is Cla
ssElement); |
| 14444 if (definingClass != null) { | 14773 if (definingClass != null) { |
| 14445 type.typeArguments = definingClass.type.typeArguments; | 14774 type.typeArguments = definingClass.type.typeArguments; |
| 14446 } | 14775 } |
| 14447 element.type = type; | 14776 element.type = type; |
| 14448 if (element is PropertyAccessorElement) { | 14777 if (element is PropertyAccessorElement) { |
| 14449 PropertyAccessorElement accessor = element as PropertyAccessorElement; | 14778 PropertyAccessorElement accessor = element as PropertyAccessorElement; |
| 14450 PropertyInducingElementImpl variable = accessor.variable as PropertyInduci
ngElementImpl; | 14779 PropertyInducingElementImpl variable = accessor.variable as PropertyInduci
ngElementImpl; |
| 14451 if (accessor.isGetter) { | 14780 if (accessor.isGetter) { |
| 14452 variable.type = type.returnType; | 14781 variable.type = type.returnType; |
| 14453 } else if (variable.type == null) { | 14782 } else if (variable.type == null) { |
| 14454 List<DartType> parameterTypes = type.normalParameterTypes; | 14783 List<DartType> parameterTypes = type.normalParameterTypes; |
| 14455 if (parameterTypes != null && parameterTypes.length > 0) { | 14784 if (parameterTypes != null && parameterTypes.length > 0) { |
| 14456 variable.type = parameterTypes[0]; | 14785 variable.type = parameterTypes[0]; |
| 14457 } | 14786 } |
| 14458 } | 14787 } |
| 14459 } | 14788 } |
| 14460 return null; | 14789 return null; |
| 14461 } | 14790 } |
| 14462 | 14791 |
| 14792 @override |
| 14463 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 14793 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 14464 super.visitSimpleFormalParameter(node); | 14794 super.visitSimpleFormalParameter(node); |
| 14465 DartType declaredType; | 14795 DartType declaredType; |
| 14466 TypeName typeName = node.type; | 14796 TypeName typeName = node.type; |
| 14467 if (typeName == null) { | 14797 if (typeName == null) { |
| 14468 declaredType = _dynamicType; | 14798 declaredType = _dynamicType; |
| 14469 } else { | 14799 } else { |
| 14470 declaredType = _getType(typeName); | 14800 declaredType = _getType(typeName); |
| 14471 } | 14801 } |
| 14472 Element element = node.identifier.staticElement; | 14802 Element element = node.identifier.staticElement; |
| 14473 if (element is ParameterElement) { | 14803 if (element is ParameterElement) { |
| 14474 (element as ParameterElementImpl).type = declaredType; | 14804 (element as ParameterElementImpl).type = declaredType; |
| 14475 } else { | 14805 } else { |
| 14476 } | 14806 } |
| 14477 return null; | 14807 return null; |
| 14478 } | 14808 } |
| 14479 | 14809 |
| 14810 @override |
| 14480 Object visitSuperExpression(SuperExpression node) { | 14811 Object visitSuperExpression(SuperExpression node) { |
| 14481 _hasReferenceToSuper = true; | 14812 _hasReferenceToSuper = true; |
| 14482 return super.visitSuperExpression(node); | 14813 return super.visitSuperExpression(node); |
| 14483 } | 14814 } |
| 14484 | 14815 |
| 14816 @override |
| 14485 Object visitTypeName(TypeName node) { | 14817 Object visitTypeName(TypeName node) { |
| 14486 super.visitTypeName(node); | 14818 super.visitTypeName(node); |
| 14487 Identifier typeName = node.name; | 14819 Identifier typeName = node.name; |
| 14488 TypeArgumentList argumentList = node.typeArguments; | 14820 TypeArgumentList argumentList = node.typeArguments; |
| 14489 Element element = nameScope.lookup(typeName, definingLibrary); | 14821 Element element = nameScope.lookup(typeName, definingLibrary); |
| 14490 if (element == null) { | 14822 if (element == null) { |
| 14491 // | 14823 // |
| 14492 // Check to see whether the type name is either 'dynamic' or 'void', neith
er of which are in | 14824 // Check to see whether the type name is either 'dynamic' or 'void', neith
er of which are in |
| 14493 // the name scope and hence will not be found by normal means. | 14825 // the name scope and hence will not be found by normal means. |
| 14494 // | 14826 // |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14697 arguments[i] = dynamicType; | 15029 arguments[i] = dynamicType; |
| 14698 } | 15030 } |
| 14699 type = type.substitute2(arguments, parameters); | 15031 type = type.substitute2(arguments, parameters); |
| 14700 } | 15032 } |
| 14701 } | 15033 } |
| 14702 typeName.staticType = type; | 15034 typeName.staticType = type; |
| 14703 node.type = type; | 15035 node.type = type; |
| 14704 return null; | 15036 return null; |
| 14705 } | 15037 } |
| 14706 | 15038 |
| 15039 @override |
| 14707 Object visitTypeParameter(TypeParameter node) { | 15040 Object visitTypeParameter(TypeParameter node) { |
| 14708 super.visitTypeParameter(node); | 15041 super.visitTypeParameter(node); |
| 14709 TypeName bound = node.bound; | 15042 TypeName bound = node.bound; |
| 14710 if (bound != null) { | 15043 if (bound != null) { |
| 14711 TypeParameterElementImpl typeParameter = node.name.staticElement as TypePa
rameterElementImpl; | 15044 TypeParameterElementImpl typeParameter = node.name.staticElement as TypePa
rameterElementImpl; |
| 14712 if (typeParameter != null) { | 15045 if (typeParameter != null) { |
| 14713 typeParameter.bound = bound.type; | 15046 typeParameter.bound = bound.type; |
| 14714 } | 15047 } |
| 14715 } | 15048 } |
| 14716 return null; | 15049 return null; |
| 14717 } | 15050 } |
| 14718 | 15051 |
| 15052 @override |
| 14719 Object visitVariableDeclaration(VariableDeclaration node) { | 15053 Object visitVariableDeclaration(VariableDeclaration node) { |
| 14720 super.visitVariableDeclaration(node); | 15054 super.visitVariableDeclaration(node); |
| 14721 DartType declaredType; | 15055 DartType declaredType; |
| 14722 TypeName typeName = (node.parent as VariableDeclarationList).type; | 15056 TypeName typeName = (node.parent as VariableDeclarationList).type; |
| 14723 if (typeName == null) { | 15057 if (typeName == null) { |
| 14724 declaredType = _dynamicType; | 15058 declaredType = _dynamicType; |
| 14725 } else { | 15059 } else { |
| 14726 declaredType = _getType(typeName); | 15060 declaredType = _getType(typeName); |
| 14727 } | 15061 } |
| 14728 Element element = node.name.staticElement; | 15062 Element element = node.name.staticElement; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 14750 setterType.typeArguments = definingClass.type.typeArguments; | 15084 setterType.typeArguments = definingClass.type.typeArguments; |
| 14751 } | 15085 } |
| 14752 setter.type = setterType; | 15086 setter.type = setterType; |
| 14753 } | 15087 } |
| 14754 } | 15088 } |
| 14755 } else { | 15089 } else { |
| 14756 } | 15090 } |
| 14757 return null; | 15091 return null; |
| 14758 } | 15092 } |
| 14759 | 15093 |
| 15094 @override |
| 14760 void visitClassDeclarationInScope(ClassDeclaration node) { | 15095 void visitClassDeclarationInScope(ClassDeclaration node) { |
| 14761 // | 15096 // |
| 14762 // Process field declarations before constructors and methods so that the ty
pes of field formal | 15097 // Process field declarations before constructors and methods so that the ty
pes of field formal |
| 14763 // parameters can be correctly resolved. | 15098 // parameters can be correctly resolved. |
| 14764 // | 15099 // |
| 14765 List<ClassMember> nonFields = new List<ClassMember>(); | 15100 List<ClassMember> nonFields = new List<ClassMember>(); |
| 14766 node.visitChildren(new UnifyingAstVisitor_TypeResolverVisitor_visitClassDecl
arationInScope(this, nonFields)); | 15101 node.visitChildren(new UnifyingAstVisitor_TypeResolverVisitor_visitClassDecl
arationInScope(this, nonFields)); |
| 14767 int count = nonFields.length; | 15102 int count = nonFields.length; |
| 14768 for (int i = 0; i < count; i++) { | 15103 for (int i = 0; i < count; i++) { |
| 14769 nonFields[i].accept(this); | 15104 nonFields[i].accept(this); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15244 RedirectingConstructorKind(String name, int ordinal) : super(name, ordinal); | 15579 RedirectingConstructorKind(String name, int ordinal) : super(name, ordinal); |
| 15245 } | 15580 } |
| 15246 | 15581 |
| 15247 class UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope extend
s UnifyingAstVisitor<Object> { | 15582 class UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope extend
s UnifyingAstVisitor<Object> { |
| 15248 final TypeResolverVisitor TypeResolverVisitor_this; | 15583 final TypeResolverVisitor TypeResolverVisitor_this; |
| 15249 | 15584 |
| 15250 List<ClassMember> nonFields; | 15585 List<ClassMember> nonFields; |
| 15251 | 15586 |
| 15252 UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope(this.TypeR
esolverVisitor_this, this.nonFields) : super(); | 15587 UnifyingAstVisitor_TypeResolverVisitor_visitClassDeclarationInScope(this.TypeR
esolverVisitor_this, this.nonFields) : super(); |
| 15253 | 15588 |
| 15589 @override |
| 15254 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 15590 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 15255 nonFields.add(node); | 15591 nonFields.add(node); |
| 15256 return null; | 15592 return null; |
| 15257 } | 15593 } |
| 15258 | 15594 |
| 15595 @override |
| 15259 Object visitMethodDeclaration(MethodDeclaration node) { | 15596 Object visitMethodDeclaration(MethodDeclaration node) { |
| 15260 nonFields.add(node); | 15597 nonFields.add(node); |
| 15261 return null; | 15598 return null; |
| 15262 } | 15599 } |
| 15263 | 15600 |
| 15601 @override |
| 15264 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 15602 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 15265 } | 15603 } |
| 15266 | 15604 |
| 15267 /** | 15605 /** |
| 15268 * Instances of the class `VariableResolverVisitor` are used to resolve | 15606 * Instances of the class `VariableResolverVisitor` are used to resolve |
| 15269 * [SimpleIdentifier]s to local variables and formal parameters. | 15607 * [SimpleIdentifier]s to local variables and formal parameters. |
| 15270 */ | 15608 */ |
| 15271 class VariableResolverVisitor extends ScopedVisitor { | 15609 class VariableResolverVisitor extends ScopedVisitor { |
| 15272 /** | 15610 /** |
| 15273 * The method or function that we are currently visiting, or `null` if we are
not inside a | 15611 * The method or function that we are currently visiting, or `null` if we are
not inside a |
| (...skipping 15 matching lines...) Expand all Loading... |
| 15289 * | 15627 * |
| 15290 * @param definingLibrary the element for the library containing the node bein
g visited | 15628 * @param definingLibrary the element for the library containing the node bein
g visited |
| 15291 * @param source the source representing the compilation unit containing the n
ode being visited | 15629 * @param source the source representing the compilation unit containing the n
ode being visited |
| 15292 * @param typeProvider the object used to access the types from the core libra
ry | 15630 * @param typeProvider the object used to access the types from the core libra
ry |
| 15293 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | 15631 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited |
| 15294 * @param errorListener the error listener that will be informed of any errors
that are found | 15632 * @param errorListener the error listener that will be informed of any errors
that are found |
| 15295 * during resolution | 15633 * during resolution |
| 15296 */ | 15634 */ |
| 15297 VariableResolverVisitor.con2(LibraryElement definingLibrary, Source source, Ty
peProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) :
super.con3(definingLibrary, source, typeProvider, nameScope, errorListener); | 15635 VariableResolverVisitor.con2(LibraryElement definingLibrary, Source source, Ty
peProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) :
super.con3(definingLibrary, source, typeProvider, nameScope, errorListener); |
| 15298 | 15636 |
| 15637 @override |
| 15299 Object visitFunctionDeclaration(FunctionDeclaration node) { | 15638 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 15300 ExecutableElement outerFunction = _enclosingFunction; | 15639 ExecutableElement outerFunction = _enclosingFunction; |
| 15301 try { | 15640 try { |
| 15302 _enclosingFunction = node.element; | 15641 _enclosingFunction = node.element; |
| 15303 return super.visitFunctionDeclaration(node); | 15642 return super.visitFunctionDeclaration(node); |
| 15304 } finally { | 15643 } finally { |
| 15305 _enclosingFunction = outerFunction; | 15644 _enclosingFunction = outerFunction; |
| 15306 } | 15645 } |
| 15307 } | 15646 } |
| 15308 | 15647 |
| 15648 @override |
| 15309 Object visitFunctionExpression(FunctionExpression node) { | 15649 Object visitFunctionExpression(FunctionExpression node) { |
| 15310 if (node.parent is! FunctionDeclaration) { | 15650 if (node.parent is! FunctionDeclaration) { |
| 15311 ExecutableElement outerFunction = _enclosingFunction; | 15651 ExecutableElement outerFunction = _enclosingFunction; |
| 15312 try { | 15652 try { |
| 15313 _enclosingFunction = node.element; | 15653 _enclosingFunction = node.element; |
| 15314 return super.visitFunctionExpression(node); | 15654 return super.visitFunctionExpression(node); |
| 15315 } finally { | 15655 } finally { |
| 15316 _enclosingFunction = outerFunction; | 15656 _enclosingFunction = outerFunction; |
| 15317 } | 15657 } |
| 15318 } else { | 15658 } else { |
| 15319 return super.visitFunctionExpression(node); | 15659 return super.visitFunctionExpression(node); |
| 15320 } | 15660 } |
| 15321 } | 15661 } |
| 15322 | 15662 |
| 15663 @override |
| 15323 Object visitSimpleIdentifier(SimpleIdentifier node) { | 15664 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 15324 // Ignore if already resolved - declaration or type. | 15665 // Ignore if already resolved - declaration or type. |
| 15325 if (node.staticElement != null) { | 15666 if (node.staticElement != null) { |
| 15326 return null; | 15667 return null; |
| 15327 } | 15668 } |
| 15328 // Ignore if qualified. | 15669 // Ignore if qualified. |
| 15329 AstNode parent = node.parent; | 15670 AstNode parent = node.parent; |
| 15330 if (parent is PrefixedIdentifier && identical(parent.identifier, node)) { | 15671 if (parent is PrefixedIdentifier && identical(parent.identifier, node)) { |
| 15331 return null; | 15672 return null; |
| 15332 } | 15673 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15381 * Initialize a newly created scope enclosed within another scope. | 15722 * Initialize a newly created scope enclosed within another scope. |
| 15382 * | 15723 * |
| 15383 * @param enclosingScope the scope in which this scope is lexically enclosed | 15724 * @param enclosingScope the scope in which this scope is lexically enclosed |
| 15384 * @param typeElement the element representing the type represented by this sc
ope | 15725 * @param typeElement the element representing the type represented by this sc
ope |
| 15385 */ | 15726 */ |
| 15386 ClassScope(Scope enclosingScope, ClassElement typeElement) : super(new Enclose
dScope(enclosingScope)) { | 15727 ClassScope(Scope enclosingScope, ClassElement typeElement) : super(new Enclose
dScope(enclosingScope)) { |
| 15387 _defineTypeParameters(typeElement); | 15728 _defineTypeParameters(typeElement); |
| 15388 _defineMembers(typeElement); | 15729 _defineMembers(typeElement); |
| 15389 } | 15730 } |
| 15390 | 15731 |
| 15732 @override |
| 15391 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 15733 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 15392 if (existing is PropertyAccessorElement && duplicate is MethodElement) { | 15734 if (existing is PropertyAccessorElement && duplicate is MethodElement) { |
| 15393 if (existing.nameOffset < duplicate.nameOffset) { | 15735 if (existing.nameOffset < duplicate.nameOffset) { |
| 15394 return new AnalysisError.con2(duplicate.source, duplicate.nameOffset, du
plicate.displayName.length, CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAM
E, [existing.displayName]); | 15736 return new AnalysisError.con2(duplicate.source, duplicate.nameOffset, du
plicate.displayName.length, CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAM
E, [existing.displayName]); |
| 15395 } else { | 15737 } else { |
| 15396 return new AnalysisError.con2(existing.source, existing.nameOffset, exis
ting.displayName.length, CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME,
[existing.displayName]); | 15738 return new AnalysisError.con2(existing.source, existing.nameOffset, exis
ting.displayName.length, CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME,
[existing.displayName]); |
| 15397 } | 15739 } |
| 15398 } | 15740 } |
| 15399 return super.getErrorForDuplicate(existing, duplicate); | 15741 return super.getErrorForDuplicate(existing, duplicate); |
| 15400 } | 15742 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15448 */ | 15790 */ |
| 15449 bool _hasHiddenName = false; | 15791 bool _hasHiddenName = false; |
| 15450 | 15792 |
| 15451 /** | 15793 /** |
| 15452 * Initialize a newly created scope enclosed within another scope. | 15794 * Initialize a newly created scope enclosed within another scope. |
| 15453 * | 15795 * |
| 15454 * @param enclosingScope the scope in which this scope is lexically enclosed | 15796 * @param enclosingScope the scope in which this scope is lexically enclosed |
| 15455 */ | 15797 */ |
| 15456 EnclosedScope(this.enclosingScope); | 15798 EnclosedScope(this.enclosingScope); |
| 15457 | 15799 |
| 15800 @override |
| 15458 AnalysisErrorListener get errorListener => enclosingScope.errorListener; | 15801 AnalysisErrorListener get errorListener => enclosingScope.errorListener; |
| 15459 | 15802 |
| 15460 /** | 15803 /** |
| 15461 * Record that given element is declared in this scope, but hasn't been initia
lized yet, so it is | 15804 * Record that given element is declared in this scope, but hasn't been initia
lized yet, so it is |
| 15462 * error to use. If there is already an element with the given name defined in
an outer scope, | 15805 * error to use. If there is already an element with the given name defined in
an outer scope, |
| 15463 * then it will become unavailable. | 15806 * then it will become unavailable. |
| 15464 * | 15807 * |
| 15465 * @param element the element declared, but not initialized in this scope | 15808 * @param element the element declared, but not initialized in this scope |
| 15466 */ | 15809 */ |
| 15467 void hide(Element element) { | 15810 void hide(Element element) { |
| 15468 if (element != null) { | 15811 if (element != null) { |
| 15469 String name = element.name; | 15812 String name = element.name; |
| 15470 if (name != null && !name.isEmpty) { | 15813 if (name != null && !name.isEmpty) { |
| 15471 _hiddenElements[name] = element; | 15814 _hiddenElements[name] = element; |
| 15472 _hasHiddenName = true; | 15815 _hasHiddenName = true; |
| 15473 } | 15816 } |
| 15474 } | 15817 } |
| 15475 } | 15818 } |
| 15476 | 15819 |
| 15820 @override |
| 15477 Element internalLookup(Identifier identifier, String name, LibraryElement refe
rencingLibrary) { | 15821 Element internalLookup(Identifier identifier, String name, LibraryElement refe
rencingLibrary) { |
| 15478 Element element = localLookup(name, referencingLibrary); | 15822 Element element = localLookup(name, referencingLibrary); |
| 15479 if (element != null) { | 15823 if (element != null) { |
| 15480 return element; | 15824 return element; |
| 15481 } | 15825 } |
| 15482 // May be there is a hidden Element. | 15826 // May be there is a hidden Element. |
| 15483 if (_hasHiddenName) { | 15827 if (_hasHiddenName) { |
| 15484 Element hiddenElement = _hiddenElements[name]; | 15828 Element hiddenElement = _hiddenElements[name]; |
| 15485 if (hiddenElement != null) { | 15829 if (hiddenElement != null) { |
| 15486 errorListener.onError(new AnalysisError.con2(getSource(identifier), iden
tifier.offset, identifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARA
TION, [])); | 15830 errorListener.onError(new AnalysisError.con2(getSource(identifier), iden
tifier.offset, identifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARA
TION, [])); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15679 * | 16023 * |
| 15680 * @param definingLibrary the element representing the library that imports th
e names defined in | 16024 * @param definingLibrary the element representing the library that imports th
e names defined in |
| 15681 * this scope | 16025 * this scope |
| 15682 * @param errorListener the listener that is to be informed when an error is e
ncountered | 16026 * @param errorListener the listener that is to be informed when an error is e
ncountered |
| 15683 */ | 16027 */ |
| 15684 LibraryImportScope(LibraryElement definingLibrary, this.errorListener) { | 16028 LibraryImportScope(LibraryElement definingLibrary, this.errorListener) { |
| 15685 this._definingLibrary = definingLibrary; | 16029 this._definingLibrary = definingLibrary; |
| 15686 _createImportedNamespaces(definingLibrary); | 16030 _createImportedNamespaces(definingLibrary); |
| 15687 } | 16031 } |
| 15688 | 16032 |
| 16033 @override |
| 15689 void define(Element element) { | 16034 void define(Element element) { |
| 15690 if (!Scope.isPrivateName(element.displayName)) { | 16035 if (!Scope.isPrivateName(element.displayName)) { |
| 15691 super.define(element); | 16036 super.define(element); |
| 15692 } | 16037 } |
| 15693 } | 16038 } |
| 15694 | 16039 |
| 16040 @override |
| 15695 Element internalLookup(Identifier identifier, String name, LibraryElement refe
rencingLibrary) { | 16041 Element internalLookup(Identifier identifier, String name, LibraryElement refe
rencingLibrary) { |
| 15696 Element foundElement = localLookup(name, referencingLibrary); | 16042 Element foundElement = localLookup(name, referencingLibrary); |
| 15697 if (foundElement != null) { | 16043 if (foundElement != null) { |
| 15698 return foundElement; | 16044 return foundElement; |
| 15699 } | 16045 } |
| 15700 for (Namespace nameSpace in _importedNamespaces) { | 16046 for (Namespace nameSpace in _importedNamespaces) { |
| 15701 Element element = nameSpace.get(name); | 16047 Element element = nameSpace.get(name); |
| 15702 if (element != null) { | 16048 if (element != null) { |
| 15703 if (foundElement == null) { | 16049 if (foundElement == null) { |
| 15704 foundElement = element; | 16050 foundElement = element; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15813 /** | 16159 /** |
| 15814 * Initialize a newly created scope representing the names defined in the give
n library. | 16160 * Initialize a newly created scope representing the names defined in the give
n library. |
| 15815 * | 16161 * |
| 15816 * @param definingLibrary the element representing the library represented by
this scope | 16162 * @param definingLibrary the element representing the library represented by
this scope |
| 15817 * @param errorListener the listener that is to be informed when an error is e
ncountered | 16163 * @param errorListener the listener that is to be informed when an error is e
ncountered |
| 15818 */ | 16164 */ |
| 15819 LibraryScope(LibraryElement definingLibrary, AnalysisErrorListener errorListen
er) : super(new LibraryImportScope(definingLibrary, errorListener)) { | 16165 LibraryScope(LibraryElement definingLibrary, AnalysisErrorListener errorListen
er) : super(new LibraryImportScope(definingLibrary, errorListener)) { |
| 15820 _defineTopLevelNames(definingLibrary); | 16166 _defineTopLevelNames(definingLibrary); |
| 15821 } | 16167 } |
| 15822 | 16168 |
| 16169 @override |
| 15823 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 16170 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 15824 if (existing is PrefixElement) { | 16171 if (existing is PrefixElement) { |
| 15825 // TODO(scheglov) consider providing actual 'nameOffset' from the syntheti
c accessor | 16172 // TODO(scheglov) consider providing actual 'nameOffset' from the syntheti
c accessor |
| 15826 int offset = duplicate.nameOffset; | 16173 int offset = duplicate.nameOffset; |
| 15827 if (duplicate is PropertyAccessorElement) { | 16174 if (duplicate is PropertyAccessorElement) { |
| 15828 PropertyAccessorElement accessor = duplicate; | 16175 PropertyAccessorElement accessor = duplicate; |
| 15829 if (accessor.isSynthetic) { | 16176 if (accessor.isSynthetic) { |
| 15830 offset = accessor.variable.nameOffset; | 16177 offset = accessor.variable.nameOffset; |
| 15831 } | 16178 } |
| 15832 } | 16179 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16481 */ | 16828 */ |
| 16482 ConstantVerifier(ErrorReporter errorReporter, TypeProvider typeProvider) { | 16829 ConstantVerifier(ErrorReporter errorReporter, TypeProvider typeProvider) { |
| 16483 this._errorReporter = errorReporter; | 16830 this._errorReporter = errorReporter; |
| 16484 this._typeProvider = typeProvider; | 16831 this._typeProvider = typeProvider; |
| 16485 this._boolType = typeProvider.boolType; | 16832 this._boolType = typeProvider.boolType; |
| 16486 this._intType = typeProvider.intType; | 16833 this._intType = typeProvider.intType; |
| 16487 this._numType = typeProvider.numType; | 16834 this._numType = typeProvider.numType; |
| 16488 this._stringType = typeProvider.stringType; | 16835 this._stringType = typeProvider.stringType; |
| 16489 } | 16836 } |
| 16490 | 16837 |
| 16838 @override |
| 16491 Object visitAnnotation(Annotation node) { | 16839 Object visitAnnotation(Annotation node) { |
| 16492 super.visitAnnotation(node); | 16840 super.visitAnnotation(node); |
| 16493 // check annotation creation | 16841 // check annotation creation |
| 16494 Element element = node.element; | 16842 Element element = node.element; |
| 16495 if (element is ConstructorElement) { | 16843 if (element is ConstructorElement) { |
| 16496 ConstructorElement constructorElement = element; | 16844 ConstructorElement constructorElement = element; |
| 16497 // should 'const' constructor | 16845 // should 'const' constructor |
| 16498 if (!constructorElement.isConst) { | 16846 if (!constructorElement.isConst) { |
| 16499 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NON_CONSTANT_ANNO
TATION_CONSTRUCTOR, node, []); | 16847 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NON_CONSTANT_ANNO
TATION_CONSTRUCTOR, node, []); |
| 16500 return null; | 16848 return null; |
| 16501 } | 16849 } |
| 16502 // should have arguments | 16850 // should have arguments |
| 16503 ArgumentList argumentList = node.arguments; | 16851 ArgumentList argumentList = node.arguments; |
| 16504 if (argumentList == null) { | 16852 if (argumentList == null) { |
| 16505 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NO_ANNOTATION_CON
STRUCTOR_ARGUMENTS, node, []); | 16853 _errorReporter.reportErrorForNode(CompileTimeErrorCode.NO_ANNOTATION_CON
STRUCTOR_ARGUMENTS, node, []); |
| 16506 return null; | 16854 return null; |
| 16507 } | 16855 } |
| 16508 // arguments should be constants | 16856 // arguments should be constants |
| 16509 _validateConstantArguments(argumentList); | 16857 _validateConstantArguments(argumentList); |
| 16510 } | 16858 } |
| 16511 return null; | 16859 return null; |
| 16512 } | 16860 } |
| 16513 | 16861 |
| 16862 @override |
| 16514 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 16863 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 16515 if (node.constKeyword != null) { | 16864 if (node.constKeyword != null) { |
| 16516 _validateInitializers(node); | 16865 _validateInitializers(node); |
| 16517 } | 16866 } |
| 16518 _validateDefaultValues(node.parameters); | 16867 _validateDefaultValues(node.parameters); |
| 16519 return super.visitConstructorDeclaration(node); | 16868 return super.visitConstructorDeclaration(node); |
| 16520 } | 16869 } |
| 16521 | 16870 |
| 16871 @override |
| 16522 Object visitFunctionExpression(FunctionExpression node) { | 16872 Object visitFunctionExpression(FunctionExpression node) { |
| 16523 super.visitFunctionExpression(node); | 16873 super.visitFunctionExpression(node); |
| 16524 _validateDefaultValues(node.parameters); | 16874 _validateDefaultValues(node.parameters); |
| 16525 return null; | 16875 return null; |
| 16526 } | 16876 } |
| 16527 | 16877 |
| 16878 @override |
| 16528 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 16879 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 16529 _validateInstanceCreationArguments(node); | 16880 _validateInstanceCreationArguments(node); |
| 16530 return super.visitInstanceCreationExpression(node); | 16881 return super.visitInstanceCreationExpression(node); |
| 16531 } | 16882 } |
| 16532 | 16883 |
| 16884 @override |
| 16533 Object visitListLiteral(ListLiteral node) { | 16885 Object visitListLiteral(ListLiteral node) { |
| 16534 super.visitListLiteral(node); | 16886 super.visitListLiteral(node); |
| 16535 if (node.constKeyword != null) { | 16887 if (node.constKeyword != null) { |
| 16536 for (Expression element in node.elements) { | 16888 for (Expression element in node.elements) { |
| 16537 _validate(element, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT); | 16889 _validate(element, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT); |
| 16538 } | 16890 } |
| 16539 } | 16891 } |
| 16540 return null; | 16892 return null; |
| 16541 } | 16893 } |
| 16542 | 16894 |
| 16895 @override |
| 16543 Object visitMapLiteral(MapLiteral node) { | 16896 Object visitMapLiteral(MapLiteral node) { |
| 16544 super.visitMapLiteral(node); | 16897 super.visitMapLiteral(node); |
| 16545 bool isConst = node.constKeyword != null; | 16898 bool isConst = node.constKeyword != null; |
| 16546 bool reportEqualKeys = true; | 16899 bool reportEqualKeys = true; |
| 16547 Set<DartObject> keys = new Set<DartObject>(); | 16900 Set<DartObject> keys = new Set<DartObject>(); |
| 16548 List<Expression> invalidKeys = new List<Expression>(); | 16901 List<Expression> invalidKeys = new List<Expression>(); |
| 16549 for (MapLiteralEntry entry in node.entries) { | 16902 for (MapLiteralEntry entry in node.entries) { |
| 16550 Expression key = entry.key; | 16903 Expression key = entry.key; |
| 16551 if (isConst) { | 16904 if (isConst) { |
| 16552 EvaluationResultImpl result = _validate(key, CompileTimeErrorCode.NON_CO
NSTANT_MAP_KEY); | 16905 EvaluationResultImpl result = _validate(key, CompileTimeErrorCode.NON_CO
NSTANT_MAP_KEY); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 16574 } | 16927 } |
| 16575 } | 16928 } |
| 16576 if (reportEqualKeys) { | 16929 if (reportEqualKeys) { |
| 16577 for (Expression key in invalidKeys) { | 16930 for (Expression key in invalidKeys) { |
| 16578 _errorReporter.reportErrorForNode(StaticWarningCode.EQUAL_KEYS_IN_MAP, k
ey, []); | 16931 _errorReporter.reportErrorForNode(StaticWarningCode.EQUAL_KEYS_IN_MAP, k
ey, []); |
| 16579 } | 16932 } |
| 16580 } | 16933 } |
| 16581 return null; | 16934 return null; |
| 16582 } | 16935 } |
| 16583 | 16936 |
| 16937 @override |
| 16584 Object visitMethodDeclaration(MethodDeclaration node) { | 16938 Object visitMethodDeclaration(MethodDeclaration node) { |
| 16585 super.visitMethodDeclaration(node); | 16939 super.visitMethodDeclaration(node); |
| 16586 _validateDefaultValues(node.parameters); | 16940 _validateDefaultValues(node.parameters); |
| 16587 return null; | 16941 return null; |
| 16588 } | 16942 } |
| 16589 | 16943 |
| 16944 @override |
| 16590 Object visitSwitchCase(SwitchCase node) { | 16945 Object visitSwitchCase(SwitchCase node) { |
| 16591 super.visitSwitchCase(node); | 16946 super.visitSwitchCase(node); |
| 16592 _validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION
); | 16947 _validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION
); |
| 16593 return null; | 16948 return null; |
| 16594 } | 16949 } |
| 16595 | 16950 |
| 16951 @override |
| 16596 Object visitVariableDeclaration(VariableDeclaration node) { | 16952 Object visitVariableDeclaration(VariableDeclaration node) { |
| 16597 super.visitVariableDeclaration(node); | 16953 super.visitVariableDeclaration(node); |
| 16598 Expression initializer = node.initializer; | 16954 Expression initializer = node.initializer; |
| 16599 if (initializer != null && node.isConst) { | 16955 if (initializer != null && node.isConst) { |
| 16600 VariableElementImpl element = node.element as VariableElementImpl; | 16956 VariableElementImpl element = node.element as VariableElementImpl; |
| 16601 EvaluationResultImpl result = element.evaluationResult; | 16957 EvaluationResultImpl result = element.evaluationResult; |
| 16602 if (result == null) { | 16958 if (result == null) { |
| 16603 // | 16959 // |
| 16604 // Normally we don't need to visit const variable declarations because w
e have already | 16960 // Normally we don't need to visit const variable declarations because w
e have already |
| 16605 // computed their values. But if we missed it for some reason, this give
s us a second | 16961 // computed their values. But if we missed it for some reason, this give
s us a second |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16758 } | 17114 } |
| 16759 } | 17115 } |
| 16760 | 17116 |
| 16761 class ConstantVisitor_ConstantVerifier_validateInitializerExpression extends Con
stantVisitor { | 17117 class ConstantVisitor_ConstantVerifier_validateInitializerExpression extends Con
stantVisitor { |
| 16762 final ConstantVerifier ConstantVerifier_this; | 17118 final ConstantVerifier ConstantVerifier_this; |
| 16763 | 17119 |
| 16764 List<ParameterElement> parameterElements; | 17120 List<ParameterElement> parameterElements; |
| 16765 | 17121 |
| 16766 ConstantVisitor_ConstantVerifier_validateInitializerExpression(TypeProvider ar
g0, this.ConstantVerifier_this, this.parameterElements) : super(arg0); | 17122 ConstantVisitor_ConstantVerifier_validateInitializerExpression(TypeProvider ar
g0, this.ConstantVerifier_this, this.parameterElements) : super(arg0); |
| 16767 | 17123 |
| 17124 @override |
| 16768 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) { | 17125 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) { |
| 16769 Element element = node.staticElement; | 17126 Element element = node.staticElement; |
| 16770 for (ParameterElement parameterElement in parameterElements) { | 17127 for (ParameterElement parameterElement in parameterElements) { |
| 16771 if (identical(parameterElement, element) && parameterElement != null) { | 17128 if (identical(parameterElement, element) && parameterElement != null) { |
| 16772 DartType type = parameterElement.type; | 17129 DartType type = parameterElement.type; |
| 16773 if (type != null) { | 17130 if (type != null) { |
| 16774 if (type.isDynamic) { | 17131 if (type.isDynamic) { |
| 16775 return ConstantVerifier_this._valid(ConstantVerifier_this._typeProvi
der.objectType, DynamicState.DYNAMIC_STATE); | 17132 return ConstantVerifier_this._valid(ConstantVerifier_this._typeProvi
der.objectType, DynamicState.DYNAMIC_STATE); |
| 16776 } else if (type.isSubtypeOf(ConstantVerifier_this._boolType)) { | 17133 } else if (type.isSubtypeOf(ConstantVerifier_this._boolType)) { |
| 16777 return ConstantVerifier_this._valid(ConstantVerifier_this._typeProvi
der.boolType, BoolState.UNKNOWN_VALUE); | 17134 return ConstantVerifier_this._valid(ConstantVerifier_this._typeProvi
der.boolType, BoolState.UNKNOWN_VALUE); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16999 _dynamicType = typeProvider.dynamicType; | 17356 _dynamicType = typeProvider.dynamicType; |
| 17000 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [ | 17357 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [ |
| 17001 typeProvider.nullType, | 17358 typeProvider.nullType, |
| 17002 typeProvider.numType, | 17359 typeProvider.numType, |
| 17003 _intType, | 17360 _intType, |
| 17004 typeProvider.doubleType, | 17361 typeProvider.doubleType, |
| 17005 _boolType, | 17362 _boolType, |
| 17006 typeProvider.stringType]; | 17363 typeProvider.stringType]; |
| 17007 } | 17364 } |
| 17008 | 17365 |
| 17366 @override |
| 17009 Object visitArgumentList(ArgumentList node) { | 17367 Object visitArgumentList(ArgumentList node) { |
| 17010 _checkForArgumentTypesNotAssignableInList(node); | 17368 _checkForArgumentTypesNotAssignableInList(node); |
| 17011 return super.visitArgumentList(node); | 17369 return super.visitArgumentList(node); |
| 17012 } | 17370 } |
| 17013 | 17371 |
| 17372 @override |
| 17014 Object visitAssertStatement(AssertStatement node) { | 17373 Object visitAssertStatement(AssertStatement node) { |
| 17015 _checkForNonBoolExpression(node); | 17374 _checkForNonBoolExpression(node); |
| 17016 return super.visitAssertStatement(node); | 17375 return super.visitAssertStatement(node); |
| 17017 } | 17376 } |
| 17018 | 17377 |
| 17378 @override |
| 17019 Object visitAssignmentExpression(AssignmentExpression node) { | 17379 Object visitAssignmentExpression(AssignmentExpression node) { |
| 17020 sc.Token operator = node.operator; | 17380 sc.Token operator = node.operator; |
| 17021 sc.TokenType operatorType = operator.type; | 17381 sc.TokenType operatorType = operator.type; |
| 17022 if (identical(operatorType, sc.TokenType.EQ)) { | 17382 if (identical(operatorType, sc.TokenType.EQ)) { |
| 17023 _checkForInvalidAssignment(node.leftHandSide, node.rightHandSide); | 17383 _checkForInvalidAssignment(node.leftHandSide, node.rightHandSide); |
| 17024 } else { | 17384 } else { |
| 17025 _checkForInvalidCompoundAssignment(node); | 17385 _checkForInvalidCompoundAssignment(node); |
| 17026 } | 17386 } |
| 17027 _checkForAssignmentToFinal(node.leftHandSide); | 17387 _checkForAssignmentToFinal(node.leftHandSide); |
| 17028 _checkForArgumentTypeNotAssignableForArgument(node.rightHandSide); | 17388 _checkForArgumentTypeNotAssignableForArgument(node.rightHandSide); |
| 17029 return super.visitAssignmentExpression(node); | 17389 return super.visitAssignmentExpression(node); |
| 17030 } | 17390 } |
| 17031 | 17391 |
| 17392 @override |
| 17032 Object visitBinaryExpression(BinaryExpression node) { | 17393 Object visitBinaryExpression(BinaryExpression node) { |
| 17033 _checkForArgumentTypeNotAssignableForArgument(node.rightOperand); | 17394 _checkForArgumentTypeNotAssignableForArgument(node.rightOperand); |
| 17034 return super.visitBinaryExpression(node); | 17395 return super.visitBinaryExpression(node); |
| 17035 } | 17396 } |
| 17036 | 17397 |
| 17398 @override |
| 17037 Object visitBlockFunctionBody(BlockFunctionBody node) { | 17399 Object visitBlockFunctionBody(BlockFunctionBody node) { |
| 17038 List<ReturnStatement> previousReturnsWith = _returnsWith; | 17400 List<ReturnStatement> previousReturnsWith = _returnsWith; |
| 17039 List<ReturnStatement> previousReturnsWithout = _returnsWithout; | 17401 List<ReturnStatement> previousReturnsWithout = _returnsWithout; |
| 17040 try { | 17402 try { |
| 17041 _returnsWith = new List<ReturnStatement>(); | 17403 _returnsWith = new List<ReturnStatement>(); |
| 17042 _returnsWithout = new List<ReturnStatement>(); | 17404 _returnsWithout = new List<ReturnStatement>(); |
| 17043 super.visitBlockFunctionBody(node); | 17405 super.visitBlockFunctionBody(node); |
| 17044 _checkForMixedReturns(node); | 17406 _checkForMixedReturns(node); |
| 17045 } finally { | 17407 } finally { |
| 17046 _returnsWith = previousReturnsWith; | 17408 _returnsWith = previousReturnsWith; |
| 17047 _returnsWithout = previousReturnsWithout; | 17409 _returnsWithout = previousReturnsWithout; |
| 17048 } | 17410 } |
| 17049 return null; | 17411 return null; |
| 17050 } | 17412 } |
| 17051 | 17413 |
| 17414 @override |
| 17052 Object visitBreakStatement(BreakStatement node) { | 17415 Object visitBreakStatement(BreakStatement node) { |
| 17053 SimpleIdentifier labelNode = node.label; | 17416 SimpleIdentifier labelNode = node.label; |
| 17054 if (labelNode != null) { | 17417 if (labelNode != null) { |
| 17055 Element labelElement = labelNode.staticElement; | 17418 Element labelElement = labelNode.staticElement; |
| 17056 if (labelElement is LabelElementImpl && labelElement.isOnSwitchMember) { | 17419 if (labelElement is LabelElementImpl && labelElement.isOnSwitchMember) { |
| 17057 _errorReporter.reportErrorForNode(ResolverErrorCode.BREAK_LABEL_ON_SWITC
H_MEMBER, labelNode, []); | 17420 _errorReporter.reportErrorForNode(ResolverErrorCode.BREAK_LABEL_ON_SWITC
H_MEMBER, labelNode, []); |
| 17058 } | 17421 } |
| 17059 } | 17422 } |
| 17060 return null; | 17423 return null; |
| 17061 } | 17424 } |
| 17062 | 17425 |
| 17426 @override |
| 17063 Object visitCatchClause(CatchClause node) { | 17427 Object visitCatchClause(CatchClause node) { |
| 17064 bool previousIsInCatchClause = _isInCatchClause; | 17428 bool previousIsInCatchClause = _isInCatchClause; |
| 17065 try { | 17429 try { |
| 17066 _isInCatchClause = true; | 17430 _isInCatchClause = true; |
| 17067 return super.visitCatchClause(node); | 17431 return super.visitCatchClause(node); |
| 17068 } finally { | 17432 } finally { |
| 17069 _isInCatchClause = previousIsInCatchClause; | 17433 _isInCatchClause = previousIsInCatchClause; |
| 17070 } | 17434 } |
| 17071 } | 17435 } |
| 17072 | 17436 |
| 17437 @override |
| 17073 Object visitClassDeclaration(ClassDeclaration node) { | 17438 Object visitClassDeclaration(ClassDeclaration node) { |
| 17074 ClassElement outerClass = _enclosingClass; | 17439 ClassElement outerClass = _enclosingClass; |
| 17075 try { | 17440 try { |
| 17076 _isInNativeClass = node.nativeClause != null; | 17441 _isInNativeClass = node.nativeClause != null; |
| 17077 _enclosingClass = node.element; | 17442 _enclosingClass = node.element; |
| 17078 WithClause withClause = node.withClause; | 17443 WithClause withClause = node.withClause; |
| 17079 ImplementsClause implementsClause = node.implementsClause; | 17444 ImplementsClause implementsClause = node.implementsClause; |
| 17080 ExtendsClause extendsClause = node.extendsClause; | 17445 ExtendsClause extendsClause = node.extendsClause; |
| 17081 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_
IDENTIFIER_AS_TYPE_NAME); | 17446 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_
IDENTIFIER_AS_TYPE_NAME); |
| 17082 _checkForMemberWithClassName(); | 17447 _checkForMemberWithClassName(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 17111 _checkForDuplicateDefinitionInheritance(); | 17476 _checkForDuplicateDefinitionInheritance(); |
| 17112 _checkForConflictingInstanceMethodSetter(node); | 17477 _checkForConflictingInstanceMethodSetter(node); |
| 17113 return super.visitClassDeclaration(node); | 17478 return super.visitClassDeclaration(node); |
| 17114 } finally { | 17479 } finally { |
| 17115 _isInNativeClass = false; | 17480 _isInNativeClass = false; |
| 17116 _initialFieldElementsMap = null; | 17481 _initialFieldElementsMap = null; |
| 17117 _enclosingClass = outerClass; | 17482 _enclosingClass = outerClass; |
| 17118 } | 17483 } |
| 17119 } | 17484 } |
| 17120 | 17485 |
| 17486 @override |
| 17121 Object visitClassTypeAlias(ClassTypeAlias node) { | 17487 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 17122 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPEDEF_NAME); | 17488 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPEDEF_NAME); |
| 17123 _checkForAllMixinErrorCodes(node.withClause); | 17489 _checkForAllMixinErrorCodes(node.withClause); |
| 17124 ClassElement outerClassElement = _enclosingClass; | 17490 ClassElement outerClassElement = _enclosingClass; |
| 17125 try { | 17491 try { |
| 17126 _enclosingClass = node.element; | 17492 _enclosingClass = node.element; |
| 17127 _checkForRecursiveInterfaceInheritance(node.element); | 17493 _checkForRecursiveInterfaceInheritance(node.element); |
| 17128 _checkForTypeAliasCannotReferenceItself_mixin(node); | 17494 _checkForTypeAliasCannotReferenceItself_mixin(node); |
| 17129 } finally { | 17495 } finally { |
| 17130 _enclosingClass = outerClassElement; | 17496 _enclosingClass = outerClassElement; |
| 17131 } | 17497 } |
| 17132 return super.visitClassTypeAlias(node); | 17498 return super.visitClassTypeAlias(node); |
| 17133 } | 17499 } |
| 17134 | 17500 |
| 17501 @override |
| 17135 Object visitComment(Comment node) { | 17502 Object visitComment(Comment node) { |
| 17136 _isInComment = true; | 17503 _isInComment = true; |
| 17137 try { | 17504 try { |
| 17138 return super.visitComment(node); | 17505 return super.visitComment(node); |
| 17139 } finally { | 17506 } finally { |
| 17140 _isInComment = false; | 17507 _isInComment = false; |
| 17141 } | 17508 } |
| 17142 } | 17509 } |
| 17143 | 17510 |
| 17511 @override |
| 17144 Object visitConditionalExpression(ConditionalExpression node) { | 17512 Object visitConditionalExpression(ConditionalExpression node) { |
| 17145 _checkForNonBoolCondition(node.condition); | 17513 _checkForNonBoolCondition(node.condition); |
| 17146 return super.visitConditionalExpression(node); | 17514 return super.visitConditionalExpression(node); |
| 17147 } | 17515 } |
| 17148 | 17516 |
| 17517 @override |
| 17149 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 17518 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 17150 ExecutableElement outerFunction = _enclosingFunction; | 17519 ExecutableElement outerFunction = _enclosingFunction; |
| 17151 try { | 17520 try { |
| 17152 _enclosingFunction = node.element; | 17521 _enclosingFunction = node.element; |
| 17153 _isEnclosingConstructorConst = node.constKeyword != null; | 17522 _isEnclosingConstructorConst = node.constKeyword != null; |
| 17154 _checkForConstConstructorWithNonFinalField(node); | 17523 _checkForConstConstructorWithNonFinalField(node); |
| 17155 _checkForConstConstructorWithNonConstSuper(node); | 17524 _checkForConstConstructorWithNonConstSuper(node); |
| 17156 _checkForConflictingConstructorNameAndMember(node); | 17525 _checkForConflictingConstructorNameAndMember(node); |
| 17157 _checkForAllFinalInitializedErrorCodes(node); | 17526 _checkForAllFinalInitializedErrorCodes(node); |
| 17158 _checkForRedirectingConstructorErrorCodes(node); | 17527 _checkForRedirectingConstructorErrorCodes(node); |
| 17159 _checkForMultipleSuperInitializers(node); | 17528 _checkForMultipleSuperInitializers(node); |
| 17160 _checkForRecursiveConstructorRedirect(node); | 17529 _checkForRecursiveConstructorRedirect(node); |
| 17161 if (!_checkForRecursiveFactoryRedirect(node)) { | 17530 if (!_checkForRecursiveFactoryRedirect(node)) { |
| 17162 _checkForAllRedirectConstructorErrorCodes(node); | 17531 _checkForAllRedirectConstructorErrorCodes(node); |
| 17163 } | 17532 } |
| 17164 _checkForUndefinedConstructorInInitializerImplicit(node); | 17533 _checkForUndefinedConstructorInInitializerImplicit(node); |
| 17165 _checkForRedirectToNonConstConstructor(node); | 17534 _checkForRedirectToNonConstConstructor(node); |
| 17166 _checkForReturnInGenerativeConstructor(node); | 17535 _checkForReturnInGenerativeConstructor(node); |
| 17167 return super.visitConstructorDeclaration(node); | 17536 return super.visitConstructorDeclaration(node); |
| 17168 } finally { | 17537 } finally { |
| 17169 _isEnclosingConstructorConst = false; | 17538 _isEnclosingConstructorConst = false; |
| 17170 _enclosingFunction = outerFunction; | 17539 _enclosingFunction = outerFunction; |
| 17171 } | 17540 } |
| 17172 } | 17541 } |
| 17173 | 17542 |
| 17543 @override |
| 17174 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 17544 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 17175 _isInConstructorInitializer = true; | 17545 _isInConstructorInitializer = true; |
| 17176 try { | 17546 try { |
| 17177 _checkForInvalidField(node); | 17547 _checkForInvalidField(node); |
| 17178 _checkForFieldInitializerNotAssignable(node); | 17548 _checkForFieldInitializerNotAssignable(node); |
| 17179 return super.visitConstructorFieldInitializer(node); | 17549 return super.visitConstructorFieldInitializer(node); |
| 17180 } finally { | 17550 } finally { |
| 17181 _isInConstructorInitializer = false; | 17551 _isInConstructorInitializer = false; |
| 17182 } | 17552 } |
| 17183 } | 17553 } |
| 17184 | 17554 |
| 17555 @override |
| 17185 Object visitContinueStatement(ContinueStatement node) { | 17556 Object visitContinueStatement(ContinueStatement node) { |
| 17186 SimpleIdentifier labelNode = node.label; | 17557 SimpleIdentifier labelNode = node.label; |
| 17187 if (labelNode != null) { | 17558 if (labelNode != null) { |
| 17188 Element labelElement = labelNode.staticElement; | 17559 Element labelElement = labelNode.staticElement; |
| 17189 if (labelElement is LabelElementImpl && labelElement.isOnSwitchStatement)
{ | 17560 if (labelElement is LabelElementImpl && labelElement.isOnSwitchStatement)
{ |
| 17190 _errorReporter.reportErrorForNode(ResolverErrorCode.CONTINUE_LABEL_ON_SW
ITCH, labelNode, []); | 17561 _errorReporter.reportErrorForNode(ResolverErrorCode.CONTINUE_LABEL_ON_SW
ITCH, labelNode, []); |
| 17191 } | 17562 } |
| 17192 } | 17563 } |
| 17193 return null; | 17564 return null; |
| 17194 } | 17565 } |
| 17195 | 17566 |
| 17567 @override |
| 17196 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 17568 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 17197 _checkForInvalidAssignment(node.identifier, node.defaultValue); | 17569 _checkForInvalidAssignment(node.identifier, node.defaultValue); |
| 17198 _checkForDefaultValueInFunctionTypedParameter(node); | 17570 _checkForDefaultValueInFunctionTypedParameter(node); |
| 17199 return super.visitDefaultFormalParameter(node); | 17571 return super.visitDefaultFormalParameter(node); |
| 17200 } | 17572 } |
| 17201 | 17573 |
| 17574 @override |
| 17202 Object visitDoStatement(DoStatement node) { | 17575 Object visitDoStatement(DoStatement node) { |
| 17203 _checkForNonBoolCondition(node.condition); | 17576 _checkForNonBoolCondition(node.condition); |
| 17204 return super.visitDoStatement(node); | 17577 return super.visitDoStatement(node); |
| 17205 } | 17578 } |
| 17206 | 17579 |
| 17580 @override |
| 17207 Object visitExportDirective(ExportDirective node) { | 17581 Object visitExportDirective(ExportDirective node) { |
| 17208 ExportElement exportElement = node.element; | 17582 ExportElement exportElement = node.element; |
| 17209 if (exportElement != null) { | 17583 if (exportElement != null) { |
| 17210 _checkForAmbiguousExport(node, exportElement); | 17584 _checkForAmbiguousExport(node, exportElement); |
| 17211 _checkForExportDuplicateLibraryName(node, exportElement); | 17585 _checkForExportDuplicateLibraryName(node, exportElement); |
| 17212 _checkForExportInternalLibrary(node, exportElement); | 17586 _checkForExportInternalLibrary(node, exportElement); |
| 17213 } | 17587 } |
| 17214 return super.visitExportDirective(node); | 17588 return super.visitExportDirective(node); |
| 17215 } | 17589 } |
| 17216 | 17590 |
| 17591 @override |
| 17217 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 17592 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 17218 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu
nction.type; | 17593 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu
nction.type; |
| 17219 DartType expectedReturnType = functionType == null ? DynamicTypeImpl.instanc
e : functionType.returnType; | 17594 DartType expectedReturnType = functionType == null ? DynamicTypeImpl.instanc
e : functionType.returnType; |
| 17220 _checkForReturnOfInvalidType(node.expression, expectedReturnType); | 17595 _checkForReturnOfInvalidType(node.expression, expectedReturnType); |
| 17221 return super.visitExpressionFunctionBody(node); | 17596 return super.visitExpressionFunctionBody(node); |
| 17222 } | 17597 } |
| 17223 | 17598 |
| 17599 @override |
| 17224 Object visitFieldDeclaration(FieldDeclaration node) { | 17600 Object visitFieldDeclaration(FieldDeclaration node) { |
| 17225 _isInStaticVariableDeclaration = node.isStatic; | 17601 _isInStaticVariableDeclaration = node.isStatic; |
| 17226 _isInInstanceVariableDeclaration = !_isInStaticVariableDeclaration; | 17602 _isInInstanceVariableDeclaration = !_isInStaticVariableDeclaration; |
| 17227 if (_isInInstanceVariableDeclaration) { | 17603 if (_isInInstanceVariableDeclaration) { |
| 17228 VariableDeclarationList variables = node.fields; | 17604 VariableDeclarationList variables = node.fields; |
| 17229 if (variables.isConst) { | 17605 if (variables.isConst) { |
| 17230 _errorReporter.reportErrorForToken(CompileTimeErrorCode.CONST_INSTANCE_F
IELD, variables.keyword, []); | 17606 _errorReporter.reportErrorForToken(CompileTimeErrorCode.CONST_INSTANCE_F
IELD, variables.keyword, []); |
| 17231 } | 17607 } |
| 17232 } | 17608 } |
| 17233 try { | 17609 try { |
| 17234 _checkForAllInvalidOverrideErrorCodesForField(node); | 17610 _checkForAllInvalidOverrideErrorCodesForField(node); |
| 17235 return super.visitFieldDeclaration(node); | 17611 return super.visitFieldDeclaration(node); |
| 17236 } finally { | 17612 } finally { |
| 17237 _isInStaticVariableDeclaration = false; | 17613 _isInStaticVariableDeclaration = false; |
| 17238 _isInInstanceVariableDeclaration = false; | 17614 _isInInstanceVariableDeclaration = false; |
| 17239 } | 17615 } |
| 17240 } | 17616 } |
| 17241 | 17617 |
| 17618 @override |
| 17242 Object visitFieldFormalParameter(FieldFormalParameter node) { | 17619 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 17243 _checkForValidField(node); | 17620 _checkForValidField(node); |
| 17244 _checkForConstFormalParameter(node); | 17621 _checkForConstFormalParameter(node); |
| 17245 _checkForPrivateOptionalParameter(node); | 17622 _checkForPrivateOptionalParameter(node); |
| 17246 _checkForFieldInitializingFormalRedirectingConstructor(node); | 17623 _checkForFieldInitializingFormalRedirectingConstructor(node); |
| 17247 return super.visitFieldFormalParameter(node); | 17624 return super.visitFieldFormalParameter(node); |
| 17248 } | 17625 } |
| 17249 | 17626 |
| 17627 @override |
| 17250 Object visitFunctionDeclaration(FunctionDeclaration node) { | 17628 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 17251 ExecutableElement outerFunction = _enclosingFunction; | 17629 ExecutableElement outerFunction = _enclosingFunction; |
| 17252 try { | 17630 try { |
| 17253 SimpleIdentifier identifier = node.name; | 17631 SimpleIdentifier identifier = node.name; |
| 17254 String methodName = ""; | 17632 String methodName = ""; |
| 17255 if (identifier != null) { | 17633 if (identifier != null) { |
| 17256 methodName = identifier.name; | 17634 methodName = identifier.name; |
| 17257 } | 17635 } |
| 17258 _enclosingFunction = node.element; | 17636 _enclosingFunction = node.element; |
| 17259 if (node.isSetter || node.isGetter) { | 17637 if (node.isSetter || node.isGetter) { |
| 17260 _checkForMismatchedAccessorTypes(node, methodName); | 17638 _checkForMismatchedAccessorTypes(node, methodName); |
| 17261 if (node.isSetter) { | 17639 if (node.isSetter) { |
| 17262 FunctionExpression functionExpression = node.functionExpression; | 17640 FunctionExpression functionExpression = node.functionExpression; |
| 17263 if (functionExpression != null) { | 17641 if (functionExpression != null) { |
| 17264 _checkForWrongNumberOfParametersForSetter(node.name, functionExpress
ion.parameters); | 17642 _checkForWrongNumberOfParametersForSetter(node.name, functionExpress
ion.parameters); |
| 17265 } | 17643 } |
| 17266 TypeName returnType = node.returnType; | 17644 TypeName returnType = node.returnType; |
| 17267 _checkForNonVoidReturnTypeForSetter(returnType); | 17645 _checkForNonVoidReturnTypeForSetter(returnType); |
| 17268 } | 17646 } |
| 17269 } | 17647 } |
| 17270 return super.visitFunctionDeclaration(node); | 17648 return super.visitFunctionDeclaration(node); |
| 17271 } finally { | 17649 } finally { |
| 17272 _enclosingFunction = outerFunction; | 17650 _enclosingFunction = outerFunction; |
| 17273 } | 17651 } |
| 17274 } | 17652 } |
| 17275 | 17653 |
| 17654 @override |
| 17276 Object visitFunctionExpression(FunctionExpression node) { | 17655 Object visitFunctionExpression(FunctionExpression node) { |
| 17277 // If this function expression is wrapped in a function declaration, don't c
hange the | 17656 // If this function expression is wrapped in a function declaration, don't c
hange the |
| 17278 // enclosingFunction field. | 17657 // enclosingFunction field. |
| 17279 if (node.parent is! FunctionDeclaration) { | 17658 if (node.parent is! FunctionDeclaration) { |
| 17280 ExecutableElement outerFunction = _enclosingFunction; | 17659 ExecutableElement outerFunction = _enclosingFunction; |
| 17281 try { | 17660 try { |
| 17282 _enclosingFunction = node.element; | 17661 _enclosingFunction = node.element; |
| 17283 return super.visitFunctionExpression(node); | 17662 return super.visitFunctionExpression(node); |
| 17284 } finally { | 17663 } finally { |
| 17285 _enclosingFunction = outerFunction; | 17664 _enclosingFunction = outerFunction; |
| 17286 } | 17665 } |
| 17287 } else { | 17666 } else { |
| 17288 return super.visitFunctionExpression(node); | 17667 return super.visitFunctionExpression(node); |
| 17289 } | 17668 } |
| 17290 } | 17669 } |
| 17291 | 17670 |
| 17671 @override |
| 17292 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 17672 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 17293 Expression functionExpression = node.function; | 17673 Expression functionExpression = node.function; |
| 17294 DartType expressionType = functionExpression.staticType; | 17674 DartType expressionType = functionExpression.staticType; |
| 17295 if (!_isFunctionType(expressionType)) { | 17675 if (!_isFunctionType(expressionType)) { |
| 17296 _errorReporter.reportErrorForNode(StaticTypeWarningCode.INVOCATION_OF_NON_
FUNCTION_EXPRESSION, functionExpression, []); | 17676 _errorReporter.reportErrorForNode(StaticTypeWarningCode.INVOCATION_OF_NON_
FUNCTION_EXPRESSION, functionExpression, []); |
| 17297 } | 17677 } |
| 17298 return super.visitFunctionExpressionInvocation(node); | 17678 return super.visitFunctionExpressionInvocation(node); |
| 17299 } | 17679 } |
| 17300 | 17680 |
| 17681 @override |
| 17301 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 17682 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 17302 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPEDEF_NAME); | 17683 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPEDEF_NAME); |
| 17303 _checkForDefaultValueInFunctionTypeAlias(node); | 17684 _checkForDefaultValueInFunctionTypeAlias(node); |
| 17304 _checkForTypeAliasCannotReferenceItself_function(node); | 17685 _checkForTypeAliasCannotReferenceItself_function(node); |
| 17305 return super.visitFunctionTypeAlias(node); | 17686 return super.visitFunctionTypeAlias(node); |
| 17306 } | 17687 } |
| 17307 | 17688 |
| 17689 @override |
| 17308 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 17690 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 17309 bool old = _isInFunctionTypedFormalParameter; | 17691 bool old = _isInFunctionTypedFormalParameter; |
| 17310 _isInFunctionTypedFormalParameter = true; | 17692 _isInFunctionTypedFormalParameter = true; |
| 17311 try { | 17693 try { |
| 17312 return super.visitFunctionTypedFormalParameter(node); | 17694 return super.visitFunctionTypedFormalParameter(node); |
| 17313 } finally { | 17695 } finally { |
| 17314 _isInFunctionTypedFormalParameter = old; | 17696 _isInFunctionTypedFormalParameter = old; |
| 17315 } | 17697 } |
| 17316 } | 17698 } |
| 17317 | 17699 |
| 17700 @override |
| 17318 Object visitIfStatement(IfStatement node) { | 17701 Object visitIfStatement(IfStatement node) { |
| 17319 _checkForNonBoolCondition(node.condition); | 17702 _checkForNonBoolCondition(node.condition); |
| 17320 return super.visitIfStatement(node); | 17703 return super.visitIfStatement(node); |
| 17321 } | 17704 } |
| 17322 | 17705 |
| 17706 @override |
| 17323 Object visitImportDirective(ImportDirective node) { | 17707 Object visitImportDirective(ImportDirective node) { |
| 17324 ImportElement importElement = node.element; | 17708 ImportElement importElement = node.element; |
| 17325 if (importElement != null) { | 17709 if (importElement != null) { |
| 17326 _checkForImportDuplicateLibraryName(node, importElement); | 17710 _checkForImportDuplicateLibraryName(node, importElement); |
| 17327 _checkForImportInternalLibrary(node, importElement); | 17711 _checkForImportInternalLibrary(node, importElement); |
| 17328 } | 17712 } |
| 17329 return super.visitImportDirective(node); | 17713 return super.visitImportDirective(node); |
| 17330 } | 17714 } |
| 17331 | 17715 |
| 17716 @override |
| 17332 Object visitIndexExpression(IndexExpression node) { | 17717 Object visitIndexExpression(IndexExpression node) { |
| 17333 _checkForArgumentTypeNotAssignableForArgument(node.index); | 17718 _checkForArgumentTypeNotAssignableForArgument(node.index); |
| 17334 return super.visitIndexExpression(node); | 17719 return super.visitIndexExpression(node); |
| 17335 } | 17720 } |
| 17336 | 17721 |
| 17722 @override |
| 17337 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 17723 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 17338 _isInConstInstanceCreation = node.isConst; | 17724 _isInConstInstanceCreation = node.isConst; |
| 17339 try { | 17725 try { |
| 17340 ConstructorName constructorName = node.constructorName; | 17726 ConstructorName constructorName = node.constructorName; |
| 17341 TypeName typeName = constructorName.type; | 17727 TypeName typeName = constructorName.type; |
| 17342 DartType type = typeName.type; | 17728 DartType type = typeName.type; |
| 17343 if (type is InterfaceType) { | 17729 if (type is InterfaceType) { |
| 17344 InterfaceType interfaceType = type; | 17730 InterfaceType interfaceType = type; |
| 17345 _checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); | 17731 _checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); |
| 17346 if (_isInConstInstanceCreation) { | 17732 if (_isInConstInstanceCreation) { |
| 17347 _checkForConstWithNonConst(node); | 17733 _checkForConstWithNonConst(node); |
| 17348 _checkForConstWithUndefinedConstructor(node); | 17734 _checkForConstWithUndefinedConstructor(node); |
| 17349 _checkForConstWithTypeParametersInCreation(node); | 17735 _checkForConstWithTypeParametersInCreation(node); |
| 17350 } else { | 17736 } else { |
| 17351 _checkForNewWithUndefinedConstructor(node); | 17737 _checkForNewWithUndefinedConstructor(node); |
| 17352 } | 17738 } |
| 17353 } | 17739 } |
| 17354 return super.visitInstanceCreationExpression(node); | 17740 return super.visitInstanceCreationExpression(node); |
| 17355 } finally { | 17741 } finally { |
| 17356 _isInConstInstanceCreation = false; | 17742 _isInConstInstanceCreation = false; |
| 17357 } | 17743 } |
| 17358 } | 17744 } |
| 17359 | 17745 |
| 17746 @override |
| 17360 Object visitListLiteral(ListLiteral node) { | 17747 Object visitListLiteral(ListLiteral node) { |
| 17361 if (node.constKeyword != null) { | 17748 if (node.constKeyword != null) { |
| 17362 TypeArgumentList typeArguments = node.typeArguments; | 17749 TypeArgumentList typeArguments = node.typeArguments; |
| 17363 if (typeArguments != null) { | 17750 if (typeArguments != null) { |
| 17364 NodeList<TypeName> arguments = typeArguments.arguments; | 17751 NodeList<TypeName> arguments = typeArguments.arguments; |
| 17365 if (arguments.length != 0) { | 17752 if (arguments.length != 0) { |
| 17366 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST); | 17753 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST); |
| 17367 } | 17754 } |
| 17368 } | 17755 } |
| 17369 } | 17756 } |
| 17370 _checkForExpectedOneListTypeArgument(node); | 17757 _checkForExpectedOneListTypeArgument(node); |
| 17371 _checkForListElementTypeNotAssignable(node); | 17758 _checkForListElementTypeNotAssignable(node); |
| 17372 return super.visitListLiteral(node); | 17759 return super.visitListLiteral(node); |
| 17373 } | 17760 } |
| 17374 | 17761 |
| 17762 @override |
| 17375 Object visitMapLiteral(MapLiteral node) { | 17763 Object visitMapLiteral(MapLiteral node) { |
| 17376 TypeArgumentList typeArguments = node.typeArguments; | 17764 TypeArgumentList typeArguments = node.typeArguments; |
| 17377 if (typeArguments != null) { | 17765 if (typeArguments != null) { |
| 17378 NodeList<TypeName> arguments = typeArguments.arguments; | 17766 NodeList<TypeName> arguments = typeArguments.arguments; |
| 17379 if (arguments.length != 0) { | 17767 if (arguments.length != 0) { |
| 17380 if (node.constKeyword != null) { | 17768 if (node.constKeyword != null) { |
| 17381 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP); | 17769 _checkForInvalidTypeArgumentInConstTypedLiteral(arguments, CompileTime
ErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP); |
| 17382 } | 17770 } |
| 17383 } | 17771 } |
| 17384 } | 17772 } |
| 17385 _checkExpectedTwoMapTypeArguments(typeArguments); | 17773 _checkExpectedTwoMapTypeArguments(typeArguments); |
| 17386 _checkForNonConstMapAsExpressionStatement(node); | 17774 _checkForNonConstMapAsExpressionStatement(node); |
| 17387 _checkForMapTypeNotAssignable(node); | 17775 _checkForMapTypeNotAssignable(node); |
| 17388 _checkForConstMapKeyExpressionTypeImplementsEquals(node); | 17776 _checkForConstMapKeyExpressionTypeImplementsEquals(node); |
| 17389 return super.visitMapLiteral(node); | 17777 return super.visitMapLiteral(node); |
| 17390 } | 17778 } |
| 17391 | 17779 |
| 17780 @override |
| 17392 Object visitMethodDeclaration(MethodDeclaration node) { | 17781 Object visitMethodDeclaration(MethodDeclaration node) { |
| 17393 ExecutableElement previousFunction = _enclosingFunction; | 17782 ExecutableElement previousFunction = _enclosingFunction; |
| 17394 try { | 17783 try { |
| 17395 _isInStaticMethod = node.isStatic; | 17784 _isInStaticMethod = node.isStatic; |
| 17396 _enclosingFunction = node.element; | 17785 _enclosingFunction = node.element; |
| 17397 SimpleIdentifier identifier = node.name; | 17786 SimpleIdentifier identifier = node.name; |
| 17398 String methodName = ""; | 17787 String methodName = ""; |
| 17399 if (identifier != null) { | 17788 if (identifier != null) { |
| 17400 methodName = identifier.name; | 17789 methodName = identifier.name; |
| 17401 } | 17790 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 17415 } | 17804 } |
| 17416 _checkForConcreteClassWithAbstractMember(node); | 17805 _checkForConcreteClassWithAbstractMember(node); |
| 17417 _checkForAllInvalidOverrideErrorCodesForMethod(node); | 17806 _checkForAllInvalidOverrideErrorCodesForMethod(node); |
| 17418 return super.visitMethodDeclaration(node); | 17807 return super.visitMethodDeclaration(node); |
| 17419 } finally { | 17808 } finally { |
| 17420 _enclosingFunction = previousFunction; | 17809 _enclosingFunction = previousFunction; |
| 17421 _isInStaticMethod = false; | 17810 _isInStaticMethod = false; |
| 17422 } | 17811 } |
| 17423 } | 17812 } |
| 17424 | 17813 |
| 17814 @override |
| 17425 Object visitMethodInvocation(MethodInvocation node) { | 17815 Object visitMethodInvocation(MethodInvocation node) { |
| 17426 Expression target = node.realTarget; | 17816 Expression target = node.realTarget; |
| 17427 SimpleIdentifier methodName = node.methodName; | 17817 SimpleIdentifier methodName = node.methodName; |
| 17428 if (target != null) { | 17818 if (target != null) { |
| 17429 ClassElement typeReference = ElementResolver.getTypeReference(target); | 17819 ClassElement typeReference = ElementResolver.getTypeReference(target); |
| 17430 _checkForStaticAccessToInstanceMember(typeReference, methodName); | 17820 _checkForStaticAccessToInstanceMember(typeReference, methodName); |
| 17431 _checkForInstanceAccessToStaticMember(typeReference, methodName); | 17821 _checkForInstanceAccessToStaticMember(typeReference, methodName); |
| 17432 } else { | 17822 } else { |
| 17433 _checkForUnqualifiedReferenceToNonLocalStaticMember(methodName); | 17823 _checkForUnqualifiedReferenceToNonLocalStaticMember(methodName); |
| 17434 } | 17824 } |
| 17435 return super.visitMethodInvocation(node); | 17825 return super.visitMethodInvocation(node); |
| 17436 } | 17826 } |
| 17437 | 17827 |
| 17828 @override |
| 17438 Object visitNativeClause(NativeClause node) { | 17829 Object visitNativeClause(NativeClause node) { |
| 17439 // TODO(brianwilkerson) Figure out the right rule for when 'native' is allow
ed. | 17830 // TODO(brianwilkerson) Figure out the right rule for when 'native' is allow
ed. |
| 17440 if (!_isInSystemLibrary) { | 17831 if (!_isInSystemLibrary) { |
| 17441 _errorReporter.reportErrorForNode(ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK
_CODE, node, []); | 17832 _errorReporter.reportErrorForNode(ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK
_CODE, node, []); |
| 17442 } | 17833 } |
| 17443 return super.visitNativeClause(node); | 17834 return super.visitNativeClause(node); |
| 17444 } | 17835 } |
| 17445 | 17836 |
| 17837 @override |
| 17446 Object visitNativeFunctionBody(NativeFunctionBody node) { | 17838 Object visitNativeFunctionBody(NativeFunctionBody node) { |
| 17447 _checkForNativeFunctionBodyInNonSDKCode(node); | 17839 _checkForNativeFunctionBodyInNonSDKCode(node); |
| 17448 return super.visitNativeFunctionBody(node); | 17840 return super.visitNativeFunctionBody(node); |
| 17449 } | 17841 } |
| 17450 | 17842 |
| 17843 @override |
| 17451 Object visitPostfixExpression(PostfixExpression node) { | 17844 Object visitPostfixExpression(PostfixExpression node) { |
| 17452 _checkForAssignmentToFinal(node.operand); | 17845 _checkForAssignmentToFinal(node.operand); |
| 17453 _checkForIntNotAssignable(node.operand); | 17846 _checkForIntNotAssignable(node.operand); |
| 17454 return super.visitPostfixExpression(node); | 17847 return super.visitPostfixExpression(node); |
| 17455 } | 17848 } |
| 17456 | 17849 |
| 17850 @override |
| 17457 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 17851 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 17458 if (node.parent is! Annotation) { | 17852 if (node.parent is! Annotation) { |
| 17459 ClassElement typeReference = ElementResolver.getTypeReference(node.prefix)
; | 17853 ClassElement typeReference = ElementResolver.getTypeReference(node.prefix)
; |
| 17460 SimpleIdentifier name = node.identifier; | 17854 SimpleIdentifier name = node.identifier; |
| 17461 _checkForStaticAccessToInstanceMember(typeReference, name); | 17855 _checkForStaticAccessToInstanceMember(typeReference, name); |
| 17462 _checkForInstanceAccessToStaticMember(typeReference, name); | 17856 _checkForInstanceAccessToStaticMember(typeReference, name); |
| 17463 } | 17857 } |
| 17464 return super.visitPrefixedIdentifier(node); | 17858 return super.visitPrefixedIdentifier(node); |
| 17465 } | 17859 } |
| 17466 | 17860 |
| 17861 @override |
| 17467 Object visitPrefixExpression(PrefixExpression node) { | 17862 Object visitPrefixExpression(PrefixExpression node) { |
| 17468 sc.TokenType operatorType = node.operator.type; | 17863 sc.TokenType operatorType = node.operator.type; |
| 17469 Expression operand = node.operand; | 17864 Expression operand = node.operand; |
| 17470 if (identical(operatorType, sc.TokenType.BANG)) { | 17865 if (identical(operatorType, sc.TokenType.BANG)) { |
| 17471 _checkForNonBoolNegationExpression(operand); | 17866 _checkForNonBoolNegationExpression(operand); |
| 17472 } else if (operatorType.isIncrementOperator) { | 17867 } else if (operatorType.isIncrementOperator) { |
| 17473 _checkForAssignmentToFinal(operand); | 17868 _checkForAssignmentToFinal(operand); |
| 17474 } | 17869 } |
| 17475 _checkForIntNotAssignable(operand); | 17870 _checkForIntNotAssignable(operand); |
| 17476 return super.visitPrefixExpression(node); | 17871 return super.visitPrefixExpression(node); |
| 17477 } | 17872 } |
| 17478 | 17873 |
| 17874 @override |
| 17479 Object visitPropertyAccess(PropertyAccess node) { | 17875 Object visitPropertyAccess(PropertyAccess node) { |
| 17480 ClassElement typeReference = ElementResolver.getTypeReference(node.realTarge
t); | 17876 ClassElement typeReference = ElementResolver.getTypeReference(node.realTarge
t); |
| 17481 SimpleIdentifier propertyName = node.propertyName; | 17877 SimpleIdentifier propertyName = node.propertyName; |
| 17482 _checkForStaticAccessToInstanceMember(typeReference, propertyName); | 17878 _checkForStaticAccessToInstanceMember(typeReference, propertyName); |
| 17483 _checkForInstanceAccessToStaticMember(typeReference, propertyName); | 17879 _checkForInstanceAccessToStaticMember(typeReference, propertyName); |
| 17484 return super.visitPropertyAccess(node); | 17880 return super.visitPropertyAccess(node); |
| 17485 } | 17881 } |
| 17486 | 17882 |
| 17883 @override |
| 17487 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 17884 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 17488 _isInConstructorInitializer = true; | 17885 _isInConstructorInitializer = true; |
| 17489 try { | 17886 try { |
| 17490 return super.visitRedirectingConstructorInvocation(node); | 17887 return super.visitRedirectingConstructorInvocation(node); |
| 17491 } finally { | 17888 } finally { |
| 17492 _isInConstructorInitializer = false; | 17889 _isInConstructorInitializer = false; |
| 17493 } | 17890 } |
| 17494 } | 17891 } |
| 17495 | 17892 |
| 17893 @override |
| 17496 Object visitRethrowExpression(RethrowExpression node) { | 17894 Object visitRethrowExpression(RethrowExpression node) { |
| 17497 _checkForRethrowOutsideCatch(node); | 17895 _checkForRethrowOutsideCatch(node); |
| 17498 return super.visitRethrowExpression(node); | 17896 return super.visitRethrowExpression(node); |
| 17499 } | 17897 } |
| 17500 | 17898 |
| 17899 @override |
| 17501 Object visitReturnStatement(ReturnStatement node) { | 17900 Object visitReturnStatement(ReturnStatement node) { |
| 17502 if (node.expression == null) { | 17901 if (node.expression == null) { |
| 17503 _returnsWithout.add(node); | 17902 _returnsWithout.add(node); |
| 17504 } else { | 17903 } else { |
| 17505 _returnsWith.add(node); | 17904 _returnsWith.add(node); |
| 17506 } | 17905 } |
| 17507 _checkForAllReturnStatementErrorCodes(node); | 17906 _checkForAllReturnStatementErrorCodes(node); |
| 17508 return super.visitReturnStatement(node); | 17907 return super.visitReturnStatement(node); |
| 17509 } | 17908 } |
| 17510 | 17909 |
| 17910 @override |
| 17511 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 17911 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 17512 _checkForConstFormalParameter(node); | 17912 _checkForConstFormalParameter(node); |
| 17513 _checkForPrivateOptionalParameter(node); | 17913 _checkForPrivateOptionalParameter(node); |
| 17514 return super.visitSimpleFormalParameter(node); | 17914 return super.visitSimpleFormalParameter(node); |
| 17515 } | 17915 } |
| 17516 | 17916 |
| 17917 @override |
| 17517 Object visitSimpleIdentifier(SimpleIdentifier node) { | 17918 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 17518 _checkForImplicitThisReferenceInInitializer(node); | 17919 _checkForImplicitThisReferenceInInitializer(node); |
| 17519 if (!_isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) { | 17920 if (!_isUnqualifiedReferenceToNonLocalStaticMemberAllowed(node)) { |
| 17520 _checkForUnqualifiedReferenceToNonLocalStaticMember(node); | 17921 _checkForUnqualifiedReferenceToNonLocalStaticMember(node); |
| 17521 } | 17922 } |
| 17522 return super.visitSimpleIdentifier(node); | 17923 return super.visitSimpleIdentifier(node); |
| 17523 } | 17924 } |
| 17524 | 17925 |
| 17926 @override |
| 17525 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 17927 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 17526 _isInConstructorInitializer = true; | 17928 _isInConstructorInitializer = true; |
| 17527 try { | 17929 try { |
| 17528 return super.visitSuperConstructorInvocation(node); | 17930 return super.visitSuperConstructorInvocation(node); |
| 17529 } finally { | 17931 } finally { |
| 17530 _isInConstructorInitializer = false; | 17932 _isInConstructorInitializer = false; |
| 17531 } | 17933 } |
| 17532 } | 17934 } |
| 17533 | 17935 |
| 17936 @override |
| 17534 Object visitSwitchStatement(SwitchStatement node) { | 17937 Object visitSwitchStatement(SwitchStatement node) { |
| 17535 _checkForInconsistentCaseExpressionTypes(node); | 17938 _checkForInconsistentCaseExpressionTypes(node); |
| 17536 _checkForSwitchExpressionNotAssignable(node); | 17939 _checkForSwitchExpressionNotAssignable(node); |
| 17537 _checkForCaseBlocksNotTerminated(node); | 17940 _checkForCaseBlocksNotTerminated(node); |
| 17538 return super.visitSwitchStatement(node); | 17941 return super.visitSwitchStatement(node); |
| 17539 } | 17942 } |
| 17540 | 17943 |
| 17944 @override |
| 17541 Object visitThisExpression(ThisExpression node) { | 17945 Object visitThisExpression(ThisExpression node) { |
| 17542 _checkForInvalidReferenceToThis(node); | 17946 _checkForInvalidReferenceToThis(node); |
| 17543 return super.visitThisExpression(node); | 17947 return super.visitThisExpression(node); |
| 17544 } | 17948 } |
| 17545 | 17949 |
| 17950 @override |
| 17546 Object visitThrowExpression(ThrowExpression node) { | 17951 Object visitThrowExpression(ThrowExpression node) { |
| 17547 _checkForConstEvalThrowsException(node); | 17952 _checkForConstEvalThrowsException(node); |
| 17548 return super.visitThrowExpression(node); | 17953 return super.visitThrowExpression(node); |
| 17549 } | 17954 } |
| 17550 | 17955 |
| 17956 @override |
| 17551 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 17957 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 17552 _checkForFinalNotInitialized(node.variables); | 17958 _checkForFinalNotInitialized(node.variables); |
| 17553 return super.visitTopLevelVariableDeclaration(node); | 17959 return super.visitTopLevelVariableDeclaration(node); |
| 17554 } | 17960 } |
| 17555 | 17961 |
| 17962 @override |
| 17556 Object visitTypeName(TypeName node) { | 17963 Object visitTypeName(TypeName node) { |
| 17557 _checkForTypeArgumentNotMatchingBounds(node); | 17964 _checkForTypeArgumentNotMatchingBounds(node); |
| 17558 _checkForTypeParameterReferencedByStatic(node); | 17965 _checkForTypeParameterReferencedByStatic(node); |
| 17559 return super.visitTypeName(node); | 17966 return super.visitTypeName(node); |
| 17560 } | 17967 } |
| 17561 | 17968 |
| 17969 @override |
| 17562 Object visitTypeParameter(TypeParameter node) { | 17970 Object visitTypeParameter(TypeParameter node) { |
| 17563 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPE_PARAMETER_NAME); | 17971 _checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_ID
ENTIFIER_AS_TYPE_PARAMETER_NAME); |
| 17564 _checkForTypeParameterSupertypeOfItsBound(node); | 17972 _checkForTypeParameterSupertypeOfItsBound(node); |
| 17565 return super.visitTypeParameter(node); | 17973 return super.visitTypeParameter(node); |
| 17566 } | 17974 } |
| 17567 | 17975 |
| 17976 @override |
| 17568 Object visitVariableDeclaration(VariableDeclaration node) { | 17977 Object visitVariableDeclaration(VariableDeclaration node) { |
| 17569 SimpleIdentifier nameNode = node.name; | 17978 SimpleIdentifier nameNode = node.name; |
| 17570 Expression initializerNode = node.initializer; | 17979 Expression initializerNode = node.initializer; |
| 17571 // do checks | 17980 // do checks |
| 17572 _checkForInvalidAssignment(nameNode, initializerNode); | 17981 _checkForInvalidAssignment(nameNode, initializerNode); |
| 17573 // visit name | 17982 // visit name |
| 17574 nameNode.accept(this); | 17983 nameNode.accept(this); |
| 17575 // visit initializer | 17984 // visit initializer |
| 17576 String name = nameNode.name; | 17985 String name = nameNode.name; |
| 17577 _namesForReferenceToDeclaredVariableInInitializer.add(name); | 17986 _namesForReferenceToDeclaredVariableInInitializer.add(name); |
| 17578 _isInInstanceVariableInitializer = _isInInstanceVariableDeclaration; | 17987 _isInInstanceVariableInitializer = _isInInstanceVariableDeclaration; |
| 17579 try { | 17988 try { |
| 17580 if (initializerNode != null) { | 17989 if (initializerNode != null) { |
| 17581 initializerNode.accept(this); | 17990 initializerNode.accept(this); |
| 17582 } | 17991 } |
| 17583 } finally { | 17992 } finally { |
| 17584 _isInInstanceVariableInitializer = false; | 17993 _isInInstanceVariableInitializer = false; |
| 17585 _namesForReferenceToDeclaredVariableInInitializer.remove(name); | 17994 _namesForReferenceToDeclaredVariableInInitializer.remove(name); |
| 17586 } | 17995 } |
| 17587 // done | 17996 // done |
| 17588 return null; | 17997 return null; |
| 17589 } | 17998 } |
| 17590 | 17999 |
| 18000 @override |
| 17591 Object visitVariableDeclarationList(VariableDeclarationList node) => super.vis
itVariableDeclarationList(node); | 18001 Object visitVariableDeclarationList(VariableDeclarationList node) => super.vis
itVariableDeclarationList(node); |
| 17592 | 18002 |
| 18003 @override |
| 17593 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 18004 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 17594 _checkForFinalNotInitialized(node.variables); | 18005 _checkForFinalNotInitialized(node.variables); |
| 17595 return super.visitVariableDeclarationStatement(node); | 18006 return super.visitVariableDeclarationStatement(node); |
| 17596 } | 18007 } |
| 17597 | 18008 |
| 18009 @override |
| 17598 Object visitWhileStatement(WhileStatement node) { | 18010 Object visitWhileStatement(WhileStatement node) { |
| 17599 _checkForNonBoolCondition(node.condition); | 18011 _checkForNonBoolCondition(node.condition); |
| 17600 return super.visitWhileStatement(node); | 18012 return super.visitWhileStatement(node); |
| 17601 } | 18013 } |
| 17602 | 18014 |
| 17603 /** | 18015 /** |
| 17604 * This verifies if the passed map literal has type arguments then there is ex
actly two. | 18016 * This verifies if the passed map literal has type arguments then there is ex
actly two. |
| 17605 * | 18017 * |
| 17606 * @param node the map literal to evaluate | 18018 * @param node the map literal to evaluate |
| 17607 * @return `true` if and only if an error code is generated on the passed node | 18019 * @return `true` if and only if an error code is generated on the passed node |
| (...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21585 | 21997 |
| 21586 class GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference extends G
eneralizingElementVisitor<Object> { | 21998 class GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference extends G
eneralizingElementVisitor<Object> { |
| 21587 Element target; | 21999 Element target; |
| 21588 | 22000 |
| 21589 List<Element> toCheck; | 22001 List<Element> toCheck; |
| 21590 | 22002 |
| 21591 GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference(this.target,
this.toCheck) : super(); | 22003 GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference(this.target,
this.toCheck) : super(); |
| 21592 | 22004 |
| 21593 bool _inClass = false; | 22005 bool _inClass = false; |
| 21594 | 22006 |
| 22007 @override |
| 21595 Object visitClassElement(ClassElement element) { | 22008 Object visitClassElement(ClassElement element) { |
| 21596 _addTypeToCheck(element.supertype); | 22009 _addTypeToCheck(element.supertype); |
| 21597 for (InterfaceType mixin in element.mixins) { | 22010 for (InterfaceType mixin in element.mixins) { |
| 21598 _addTypeToCheck(mixin); | 22011 _addTypeToCheck(mixin); |
| 21599 } | 22012 } |
| 21600 _inClass = !element.isTypedef; | 22013 _inClass = !element.isTypedef; |
| 21601 try { | 22014 try { |
| 21602 return super.visitClassElement(element); | 22015 return super.visitClassElement(element); |
| 21603 } finally { | 22016 } finally { |
| 21604 _inClass = false; | 22017 _inClass = false; |
| 21605 } | 22018 } |
| 21606 } | 22019 } |
| 21607 | 22020 |
| 22021 @override |
| 21608 Object visitExecutableElement(ExecutableElement element) { | 22022 Object visitExecutableElement(ExecutableElement element) { |
| 21609 if (element.isSynthetic) { | 22023 if (element.isSynthetic) { |
| 21610 return null; | 22024 return null; |
| 21611 } | 22025 } |
| 21612 _addTypeToCheck(element.returnType); | 22026 _addTypeToCheck(element.returnType); |
| 21613 return super.visitExecutableElement(element); | 22027 return super.visitExecutableElement(element); |
| 21614 } | 22028 } |
| 21615 | 22029 |
| 22030 @override |
| 21616 Object visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { | 22031 Object visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { |
| 21617 _addTypeToCheck(element.returnType); | 22032 _addTypeToCheck(element.returnType); |
| 21618 return super.visitFunctionTypeAliasElement(element); | 22033 return super.visitFunctionTypeAliasElement(element); |
| 21619 } | 22034 } |
| 21620 | 22035 |
| 22036 @override |
| 21621 Object visitParameterElement(ParameterElement element) { | 22037 Object visitParameterElement(ParameterElement element) { |
| 21622 _addTypeToCheck(element.type); | 22038 _addTypeToCheck(element.type); |
| 21623 return super.visitParameterElement(element); | 22039 return super.visitParameterElement(element); |
| 21624 } | 22040 } |
| 21625 | 22041 |
| 22042 @override |
| 21626 Object visitTypeParameterElement(TypeParameterElement element) { | 22043 Object visitTypeParameterElement(TypeParameterElement element) { |
| 21627 _addTypeToCheck(element.bound); | 22044 _addTypeToCheck(element.bound); |
| 21628 return super.visitTypeParameterElement(element); | 22045 return super.visitTypeParameterElement(element); |
| 21629 } | 22046 } |
| 21630 | 22047 |
| 22048 @override |
| 21631 Object visitVariableElement(VariableElement element) { | 22049 Object visitVariableElement(VariableElement element) { |
| 21632 _addTypeToCheck(element.type); | 22050 _addTypeToCheck(element.type); |
| 21633 return super.visitVariableElement(element); | 22051 return super.visitVariableElement(element); |
| 21634 } | 22052 } |
| 21635 | 22053 |
| 21636 void _addTypeToCheck(DartType type) { | 22054 void _addTypeToCheck(DartType type) { |
| 21637 if (type == null) { | 22055 if (type == null) { |
| 21638 return; | 22056 return; |
| 21639 } | 22057 } |
| 21640 Element element = type.element; | 22058 Element element = type.element; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21700 * Initialize a newly created error code to have the given type, message and c
orrection. | 22118 * Initialize a newly created error code to have the given type, message and c
orrection. |
| 21701 * | 22119 * |
| 21702 * @param type the type of this error | 22120 * @param type the type of this error |
| 21703 * @param message the template used to create the message to be displayed for
the error | 22121 * @param message the template used to create the message to be displayed for
the error |
| 21704 * @param correction the template used to create the correction to be displaye
d for the error | 22122 * @param correction the template used to create the correction to be displaye
d for the error |
| 21705 */ | 22123 */ |
| 21706 ResolverErrorCode.con2(String name, int ordinal, this.type, this.message, Stri
ng correction) : super(name, ordinal) { | 22124 ResolverErrorCode.con2(String name, int ordinal, this.type, this.message, Stri
ng correction) : super(name, ordinal) { |
| 21707 this.correction9 = correction; | 22125 this.correction9 = correction; |
| 21708 } | 22126 } |
| 21709 | 22127 |
| 22128 @override |
| 21710 String get correction => correction9; | 22129 String get correction => correction9; |
| 21711 | 22130 |
| 22131 @override |
| 21712 ErrorSeverity get errorSeverity => type.severity; | 22132 ErrorSeverity get errorSeverity => type.severity; |
| 21713 } | 22133 } |
| OLD | NEW |