Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/resolver.dart

Issue 12543003: Use limited JavaStringBuilder implementation instead of Dart StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver; 4 library engine.resolver;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'java_core.dart'; 7 import 'java_core.dart';
8 import 'java_engine.dart'; 8 import 'java_engine.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'error.dart'; 10 import 'error.dart';
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 return null; 862 return null;
863 } 863 }
864 Object visitMethodInvocation(MethodInvocation node) { 864 Object visitMethodInvocation(MethodInvocation node) {
865 SimpleIdentifier methodName2 = node.methodName; 865 SimpleIdentifier methodName2 = node.methodName;
866 Expression target = node.realTarget; 866 Expression target = node.realTarget;
867 Element element; 867 Element element;
868 if (target == null) { 868 if (target == null) {
869 element = _resolver.nameScope.lookup(methodName2, _resolver.definingLibrar y); 869 element = _resolver.nameScope.lookup(methodName2, _resolver.definingLibrar y);
870 if (element == null) { 870 if (element == null) {
871 element = lookUpMethod(_resolver.enclosingClass, methodName2.name); 871 element = lookUpMethod(_resolver.enclosingClass, methodName2.name);
872 if (element == null) {
873 PropertyAccessorElement getter = lookUpGetter(_resolver.enclosingClass , methodName2.name);
874 if (getter != null) {
875 FunctionType getterType = getter.type;
876 if (getterType != null) {
877 Type2 returnType4 = getterType.returnType;
878 if (!returnType4.isDynamic() && returnType4 is! FunctionType && !r eturnType4.isDartCoreFunction()) {
879 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FU NCTION, methodName2, [methodName2.name]);
880 }
881 }
882 recordResolution(methodName2, getter);
883 return null;
884 }
885 }
872 } 886 }
873 } else { 887 } else {
874 Type2 targetType = getType(target); 888 Type2 targetType = getType(target);
875 if (targetType is InterfaceType) { 889 if (targetType is InterfaceType) {
876 element = lookUpMethod(targetType.element, methodName2.name); 890 element = lookUpMethod(targetType.element, methodName2.name);
877 if (element == null) { 891 if (element == null) {
878 PropertyAccessorElement accessor = lookUpGetterInType((targetType.elem ent as ClassElement), methodName2.name); 892 PropertyAccessorElement accessor = lookUpGetterInType((targetType.elem ent as ClassElement), methodName2.name);
879 if (accessor != null) { 893 if (accessor != null) {
880 Type2 returnType4 = accessor.type.returnType; 894 Type2 returnType5 = accessor.type.returnType;
881 if (!returnType4.isDynamic() && returnType4 is! FunctionType) { 895 if (!returnType5.isDynamic() && returnType5 is! FunctionType && !ret urnType5.isDartCoreFunction()) {
882 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNC TION, methodName2, [methodName2.name]); 896 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNC TION, methodName2, [methodName2.name]);
883 return null; 897 return null;
884 } 898 }
885 element = accessor; 899 element = accessor;
886 } 900 }
887 } 901 }
888 if (element == null && target is SuperExpression) { 902 if (element == null && target is SuperExpression) {
889 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me thodName2, [methodName2.name, targetType.element.name]); 903 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me thodName2, [methodName2.name, targetType.element.name]);
890 return null; 904 return null;
891 } 905 }
(...skipping 11 matching lines...) Expand all
903 } 917 }
904 } 918 }
905 ExecutableElement invokedMethod = null; 919 ExecutableElement invokedMethod = null;
906 if (element is ExecutableElement) { 920 if (element is ExecutableElement) {
907 invokedMethod = element as ExecutableElement; 921 invokedMethod = element as ExecutableElement;
908 } else { 922 } else {
909 if (element is PropertyInducingElement) { 923 if (element is PropertyInducingElement) {
910 PropertyAccessorElement getter3 = ((element as PropertyInducingElement)) .getter; 924 PropertyAccessorElement getter3 = ((element as PropertyInducingElement)) .getter;
911 FunctionType getterType = getter3.type; 925 FunctionType getterType = getter3.type;
912 if (getterType != null) { 926 if (getterType != null) {
913 Type2 returnType5 = getterType.returnType; 927 Type2 returnType6 = getterType.returnType;
914 if (!returnType5.isDynamic() && returnType5 is! FunctionType) { 928 if (!returnType6.isDynamic() && returnType6 is! FunctionType && !retur nType6.isDartCoreFunction()) {
915 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTI ON, methodName2, [methodName2.name]); 929 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTI ON, methodName2, [methodName2.name]);
916 } 930 }
917 } 931 }
918 recordResolution(methodName2, element); 932 recordResolution(methodName2, element);
919 return null; 933 return null;
920 } else if (element is VariableElement) { 934 } else if (element is VariableElement) {
921 Type2 variableType = ((element as VariableElement)).type; 935 Type2 variableType = ((element as VariableElement)).type;
922 if (!variableType.isDynamic() && variableType is! FunctionType) { 936 if (!variableType.isDynamic() && variableType is! FunctionType && !varia bleType.isDartCoreFunction()) {
923 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION , methodName2, [methodName2.name]); 937 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION , methodName2, [methodName2.name]);
924 } 938 }
925 recordResolution(methodName2, element); 939 recordResolution(methodName2, element);
926 return null; 940 return null;
927 } else { 941 } else {
928 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]); 942 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
929 return null; 943 return null;
930 } 944 }
931 } 945 }
932 recordResolution(methodName2, invokedMethod); 946 recordResolution(methodName2, invokedMethod);
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 this._libraryElement = libraryElement2; 1796 this._libraryElement = libraryElement2;
1783 } 1797 }
1784 String toString() => _librarySource.shortName; 1798 String toString() => _librarySource.shortName;
1785 /** 1799 /**
1786 * Append the value of the given string literal to the given string builder. 1800 * Append the value of the given string literal to the given string builder.
1787 * @param builder the builder to which the string's value is to be appended 1801 * @param builder the builder to which the string's value is to be appended
1788 * @param literal the string literal whose value is to be appended to the buil der 1802 * @param literal the string literal whose value is to be appended to the buil der
1789 * @throws IllegalArgumentException if the string is not a constant string wit hout any string 1803 * @throws IllegalArgumentException if the string is not a constant string wit hout any string
1790 * interpolation 1804 * interpolation
1791 */ 1805 */
1792 void appendStringValue(StringBuffer builder, StringLiteral literal) { 1806 void appendStringValue(JavaStringBuilder builder, StringLiteral literal) {
1793 if (literal is SimpleStringLiteral) { 1807 if (literal is SimpleStringLiteral) {
1794 builder.write(((literal as SimpleStringLiteral)).value); 1808 builder.append(((literal as SimpleStringLiteral)).value);
1795 } else if (literal is AdjacentStrings) { 1809 } else if (literal is AdjacentStrings) {
1796 for (StringLiteral stringLiteral in ((literal as AdjacentStrings)).strings ) { 1810 for (StringLiteral stringLiteral in ((literal as AdjacentStrings)).strings ) {
1797 appendStringValue(builder, stringLiteral); 1811 appendStringValue(builder, stringLiteral);
1798 } 1812 }
1799 } else { 1813 } else {
1800 throw new IllegalArgumentException(); 1814 throw new IllegalArgumentException();
1801 } 1815 }
1802 } 1816 }
1803 /** 1817 /**
1804 * Return the result of resolving the given URI against the URI of the library , or {@code null} if 1818 * Return the result of resolving the given URI against the URI of the library , or {@code null} if
1805 * the URI is not valid. 1819 * the URI is not valid.
1806 * @param uri the URI to be resolved 1820 * @param uri the URI to be resolved
1807 * @return the result of resolving the given URI against the URI of the librar y 1821 * @return the result of resolving the given URI against the URI of the librar y
1808 */ 1822 */
1809 Source getSource2(String uri) { 1823 Source getSource2(String uri) {
1810 if (uri == null) { 1824 if (uri == null) {
1811 return null; 1825 return null;
1812 } 1826 }
1813 return _librarySource.resolve(uri); 1827 return _librarySource.resolve(uri);
1814 } 1828 }
1815 /** 1829 /**
1816 * Return the value of the given string literal, or {@code null} if the string is not a constant 1830 * Return the value of the given string literal, or {@code null} if the string is not a constant
1817 * string without any string interpolation. 1831 * string without any string interpolation.
1818 * @param literal the string literal whose value is to be returned 1832 * @param literal the string literal whose value is to be returned
1819 * @return the value of the given string literal 1833 * @return the value of the given string literal
1820 */ 1834 */
1821 String getStringValue(StringLiteral literal) { 1835 String getStringValue(StringLiteral literal) {
1822 StringBuffer builder = new StringBuffer(); 1836 JavaStringBuilder builder = new JavaStringBuilder();
1823 try { 1837 try {
1824 appendStringValue(builder, literal); 1838 appendStringValue(builder, literal);
1825 } on IllegalArgumentException catch (exception) { 1839 } on IllegalArgumentException catch (exception) {
1826 return null; 1840 return null;
1827 } 1841 }
1828 return builder.toString().trim(); 1842 return builder.toString().trim();
1829 } 1843 }
1830 } 1844 }
1831 /** 1845 /**
1832 * Instances of the class {@code LibraryElementBuilder} build an element model f or a single library. 1846 * Instances of the class {@code LibraryElementBuilder} build an element model f or a single library.
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 */ 3460 */
3447 Object visitThrowExpression(ThrowExpression node) => recordType(node, _typePro vider.bottomType); 3461 Object visitThrowExpression(ThrowExpression node) => recordType(node, _typePro vider.bottomType);
3448 /** 3462 /**
3449 * Given a function declaration, compute the return type of the function. The return type of 3463 * Given a function declaration, compute the return type of the function. The return type of
3450 * functions with a block body is {@code dynamicType}, with an expression body it is the type of 3464 * functions with a block body is {@code dynamicType}, with an expression body it is the type of
3451 * the expression. 3465 * the expression.
3452 * @param node the function expression whose return type is to be computed 3466 * @param node the function expression whose return type is to be computed
3453 * @return the return type that was computed 3467 * @return the return type that was computed
3454 */ 3468 */
3455 Type2 computeReturnType(FunctionDeclaration node) { 3469 Type2 computeReturnType(FunctionDeclaration node) {
3456 TypeName returnType6 = node.returnType; 3470 TypeName returnType7 = node.returnType;
3457 if (returnType6 == null) { 3471 if (returnType7 == null) {
3458 return computeReturnType2(node.functionExpression); 3472 return computeReturnType2(node.functionExpression);
3459 } 3473 }
3460 return returnType6.type; 3474 return returnType7.type;
3461 } 3475 }
3462 /** 3476 /**
3463 * Given a function expression, compute the return type of the function. The r eturn type of 3477 * Given a function expression, compute the return type of the function. The r eturn type of
3464 * functions with a block body is {@code dynamicType}, with an expression body it is the type of 3478 * functions with a block body is {@code dynamicType}, with an expression body it is the type of
3465 * the expression. 3479 * the expression.
3466 * @param node the function expression whose return type is to be computed 3480 * @param node the function expression whose return type is to be computed
3467 * @return the return type that was computed 3481 * @return the return type that was computed
3468 */ 3482 */
3469 Type2 computeReturnType2(FunctionExpression node) { 3483 Type2 computeReturnType2(FunctionExpression node) {
3470 FunctionBody body4 = node.body; 3484 FunctionBody body4 = node.body;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 } 3591 }
3578 return null; 3592 return null;
3579 } 3593 }
3580 /** 3594 /**
3581 * Set the return type and parameter type information for the given function t ype based on the 3595 * Set the return type and parameter type information for the given function t ype based on the
3582 * given return type and parameter elements. 3596 * given return type and parameter elements.
3583 * @param functionType the function type to be filled in 3597 * @param functionType the function type to be filled in
3584 * @param returnType the return type of the function, or {@code null} if no ty pe was declared 3598 * @param returnType the return type of the function, or {@code null} if no ty pe was declared
3585 * @param parameters the elements representing the parameters to the function 3599 * @param parameters the elements representing the parameters to the function
3586 */ 3600 */
3587 void setTypeInformation(FunctionTypeImpl functionType, Type2 returnType9, Form alParameterList parameterList) { 3601 void setTypeInformation(FunctionTypeImpl functionType, Type2 returnType10, For malParameterList parameterList) {
3588 List<Type2> normalParameterTypes = new List<Type2>(); 3602 List<Type2> normalParameterTypes = new List<Type2>();
3589 List<Type2> optionalParameterTypes = new List<Type2>(); 3603 List<Type2> optionalParameterTypes = new List<Type2>();
3590 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>(); 3604 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
3591 if (parameterList != null) { 3605 if (parameterList != null) {
3592 for (ParameterElement parameter in parameterList.elements) { 3606 for (ParameterElement parameter in parameterList.elements) {
3593 while (true) { 3607 while (true) {
3594 if (parameter.parameterKind == ParameterKind.REQUIRED) { 3608 if (parameter.parameterKind == ParameterKind.REQUIRED) {
3595 normalParameterTypes.add(parameter.type); 3609 normalParameterTypes.add(parameter.type);
3596 } else if (parameter.parameterKind == ParameterKind.POSITIONAL) { 3610 } else if (parameter.parameterKind == ParameterKind.POSITIONAL) {
3597 optionalParameterTypes.add(parameter.type); 3611 optionalParameterTypes.add(parameter.type);
3598 } else if (parameter.parameterKind == ParameterKind.NAMED) { 3612 } else if (parameter.parameterKind == ParameterKind.NAMED) {
3599 namedParameterTypes[parameter.name] = parameter.type; 3613 namedParameterTypes[parameter.name] = parameter.type;
3600 } 3614 }
3601 break; 3615 break;
3602 } 3616 }
3603 } 3617 }
3604 } 3618 }
3605 functionType.normalParameterTypes = new List.from(normalParameterTypes); 3619 functionType.normalParameterTypes = new List.from(normalParameterTypes);
3606 functionType.optionalParameterTypes = new List.from(optionalParameterTypes); 3620 functionType.optionalParameterTypes = new List.from(optionalParameterTypes);
3607 functionType.namedParameterTypes = namedParameterTypes; 3621 functionType.namedParameterTypes = namedParameterTypes;
3608 functionType.returnType = returnType9; 3622 functionType.returnType = returnType10;
3609 } 3623 }
3610 } 3624 }
3611 /** 3625 /**
3612 * The interface {@code TypeProvider} defines the behavior of objects that provi de access to types 3626 * The interface {@code TypeProvider} defines the behavior of objects that provi de access to types
3613 * defined by the language. 3627 * defined by the language.
3614 */ 3628 */
3615 abstract class TypeProvider { 3629 abstract class TypeProvider {
3616 /** 3630 /**
3617 * Return the type representing the built-in type 'bool'. 3631 * Return the type representing the built-in type 'bool'.
3618 * @return the type representing the built-in type 'bool' 3632 * @return the type representing the built-in type 'bool'
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4286 } 4300 }
4287 } 4301 }
4288 } 4302 }
4289 /** 4303 /**
4290 * Set the return type and parameter type information for the given function t ype based on the 4304 * Set the return type and parameter type information for the given function t ype based on the
4291 * given return type and parameter elements. 4305 * given return type and parameter elements.
4292 * @param functionType the function type to be filled in 4306 * @param functionType the function type to be filled in
4293 * @param returnType the return type of the function, or {@code null} if no ty pe was declared 4307 * @param returnType the return type of the function, or {@code null} if no ty pe was declared
4294 * @param parameters the elements representing the parameters to the function 4308 * @param parameters the elements representing the parameters to the function
4295 */ 4309 */
4296 void setTypeInformation(FunctionTypeImpl functionType, TypeName returnType10, List<ParameterElement> parameters) { 4310 void setTypeInformation(FunctionTypeImpl functionType, TypeName returnType11, List<ParameterElement> parameters) {
4297 List<Type2> normalParameterTypes = new List<Type2>(); 4311 List<Type2> normalParameterTypes = new List<Type2>();
4298 List<Type2> optionalParameterTypes = new List<Type2>(); 4312 List<Type2> optionalParameterTypes = new List<Type2>();
4299 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>(); 4313 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
4300 for (ParameterElement parameter in parameters) { 4314 for (ParameterElement parameter in parameters) {
4301 while (true) { 4315 while (true) {
4302 if (parameter.parameterKind == ParameterKind.REQUIRED) { 4316 if (parameter.parameterKind == ParameterKind.REQUIRED) {
4303 normalParameterTypes.add(parameter.type); 4317 normalParameterTypes.add(parameter.type);
4304 } else if (parameter.parameterKind == ParameterKind.POSITIONAL) { 4318 } else if (parameter.parameterKind == ParameterKind.POSITIONAL) {
4305 optionalParameterTypes.add(parameter.type); 4319 optionalParameterTypes.add(parameter.type);
4306 } else if (parameter.parameterKind == ParameterKind.NAMED) { 4320 } else if (parameter.parameterKind == ParameterKind.NAMED) {
4307 namedParameterTypes[parameter.name] = parameter.type; 4321 namedParameterTypes[parameter.name] = parameter.type;
4308 } 4322 }
4309 break; 4323 break;
4310 } 4324 }
4311 } 4325 }
4312 if (!normalParameterTypes.isEmpty) { 4326 if (!normalParameterTypes.isEmpty) {
4313 functionType.normalParameterTypes = new List.from(normalParameterTypes); 4327 functionType.normalParameterTypes = new List.from(normalParameterTypes);
4314 } 4328 }
4315 if (!optionalParameterTypes.isEmpty) { 4329 if (!optionalParameterTypes.isEmpty) {
4316 functionType.optionalParameterTypes = new List.from(optionalParameterTypes ); 4330 functionType.optionalParameterTypes = new List.from(optionalParameterTypes );
4317 } 4331 }
4318 if (!namedParameterTypes.isEmpty) { 4332 if (!namedParameterTypes.isEmpty) {
4319 functionType.namedParameterTypes = namedParameterTypes; 4333 functionType.namedParameterTypes = namedParameterTypes;
4320 } 4334 }
4321 if (returnType10 == null) { 4335 if (returnType11 == null) {
4322 functionType.returnType = _dynamicType; 4336 functionType.returnType = _dynamicType;
4323 } else { 4337 } else {
4324 functionType.returnType = returnType10.type; 4338 functionType.returnType = returnType11.type;
4325 } 4339 }
4326 } 4340 }
4327 } 4341 }
4328 /** 4342 /**
4329 * Instances of the class {@code ClassScope} implement the scope defined by a cl ass. 4343 * Instances of the class {@code ClassScope} implement the scope defined by a cl ass.
4330 */ 4344 */
4331 class ClassScope extends EnclosedScope { 4345 class ClassScope extends EnclosedScope {
4332 /** 4346 /**
4333 * Initialize a newly created scope enclosed within another scope. 4347 * Initialize a newly created scope enclosed within another scope.
4334 * @param enclosingScope the scope in which this scope is lexically enclosed 4348 * @param enclosingScope the scope in which this scope is lexically enclosed
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
5160 Object visitAssignmentExpression(AssignmentExpression node) { 5174 Object visitAssignmentExpression(AssignmentExpression node) {
5161 Expression lhs = node.leftHandSide; 5175 Expression lhs = node.leftHandSide;
5162 Expression rhs = node.rightHandSide; 5176 Expression rhs = node.rightHandSide;
5163 Type2 leftType = getType(lhs); 5177 Type2 leftType = getType(lhs);
5164 Type2 rightType = getType(rhs); 5178 Type2 rightType = getType(rhs);
5165 if (!rightType.isAssignableTo(leftType)) { 5179 if (!rightType.isAssignableTo(leftType)) {
5166 _errorReporter.reportError(StaticTypeWarningCode.INVALID_ASSIGNMENT, rhs, [leftType.name, rightType.name]); 5180 _errorReporter.reportError(StaticTypeWarningCode.INVALID_ASSIGNMENT, rhs, [leftType.name, rightType.name]);
5167 } 5181 }
5168 return super.visitAssignmentExpression(node); 5182 return super.visitAssignmentExpression(node);
5169 } 5183 }
5184 Object visitClassDeclaration(ClassDeclaration node) {
5185 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE NTIFIER_AS_TYPE_NAME);
5186 return super.visitClassDeclaration(node);
5187 }
5188 Object visitClassTypeAlias(ClassTypeAlias node) {
5189 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE NTIFIER_AS_TYPEDEF_NAME);
5190 return super.visitClassTypeAlias(node);
5191 }
5170 Object visitConditionalExpression(ConditionalExpression node) { 5192 Object visitConditionalExpression(ConditionalExpression node) {
5171 checkForNonBoolCondition(node.condition); 5193 checkForNonBoolCondition(node.condition);
5172 return super.visitConditionalExpression(node); 5194 return super.visitConditionalExpression(node);
5173 } 5195 }
5174 Object visitConstructorDeclaration(ConstructorDeclaration node) { 5196 Object visitConstructorDeclaration(ConstructorDeclaration node) {
5175 ExecutableElement previousFunction = _currentFunction; 5197 ExecutableElement previousFunction = _currentFunction;
5176 try { 5198 try {
5177 _currentFunction = node.element; 5199 _currentFunction = node.element;
5178 return super.visitConstructorDeclaration(node); 5200 return super.visitConstructorDeclaration(node);
5179 } finally { 5201 } finally {
(...skipping 15 matching lines...) Expand all
5195 } 5217 }
5196 Object visitFunctionExpression(FunctionExpression node) { 5218 Object visitFunctionExpression(FunctionExpression node) {
5197 ExecutableElement previousFunction = _currentFunction; 5219 ExecutableElement previousFunction = _currentFunction;
5198 try { 5220 try {
5199 _currentFunction = node.element; 5221 _currentFunction = node.element;
5200 return super.visitFunctionExpression(node); 5222 return super.visitFunctionExpression(node);
5201 } finally { 5223 } finally {
5202 _currentFunction = previousFunction; 5224 _currentFunction = previousFunction;
5203 } 5225 }
5204 } 5226 }
5227 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
5228 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE NTIFIER_AS_TYPEDEF_NAME);
5229 return super.visitFunctionTypeAlias(node);
5230 }
5205 Object visitIfStatement(IfStatement node) { 5231 Object visitIfStatement(IfStatement node) {
5206 checkForNonBoolCondition(node.condition); 5232 checkForNonBoolCondition(node.condition);
5207 return super.visitIfStatement(node); 5233 return super.visitIfStatement(node);
5208 } 5234 }
5209 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 5235 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
5210 ConstructorName constructorName4 = node.constructorName; 5236 ConstructorName constructorName4 = node.constructorName;
5211 TypeName typeName = constructorName4.type; 5237 TypeName typeName = constructorName4.type;
5212 Type2 createdType = typeName.type; 5238 Type2 createdType = typeName.type;
5213 if (createdType is InterfaceType) { 5239 if (createdType is InterfaceType) {
5214 if (((createdType as InterfaceType)).element.isAbstract()) { 5240 if (((createdType as InterfaceType)).element.isAbstract()) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5258 Type2 expectedReturnType = functionType == null ? null : functionType.return Type; 5284 Type2 expectedReturnType = functionType == null ? null : functionType.return Type;
5259 Expression returnExpression = node.expression; 5285 Expression returnExpression = node.expression;
5260 if (expectedReturnType != null && !expectedReturnType.isVoid() && returnExpr ession != null) { 5286 if (expectedReturnType != null && !expectedReturnType.isVoid() && returnExpr ession != null) {
5261 Type2 actualReturnType = getType(returnExpression); 5287 Type2 actualReturnType = getType(returnExpression);
5262 if (!actualReturnType.isAssignableTo(expectedReturnType)) { 5288 if (!actualReturnType.isAssignableTo(expectedReturnType)) {
5263 _errorReporter.reportError(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [actualReturnType.name, expectedReturnType.name]); 5289 _errorReporter.reportError(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [actualReturnType.name, expectedReturnType.name]);
5264 } 5290 }
5265 } 5291 }
5266 return super.visitReturnStatement(node); 5292 return super.visitReturnStatement(node);
5267 } 5293 }
5294 Object visitTypeParameter(TypeParameter node) {
5295 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE NTIFIER_AS_TYPE_VARIABLE_NAME);
5296 return super.visitTypeParameter(node);
5297 }
5268 Object visitWhileStatement(WhileStatement node) { 5298 Object visitWhileStatement(WhileStatement node) {
5269 checkForNonBoolCondition(node.condition); 5299 checkForNonBoolCondition(node.condition);
5270 return super.visitWhileStatement(node); 5300 return super.visitWhileStatement(node);
5271 } 5301 }
5272 /** 5302 /**
5303 * This verifies that the passed identifier is not a keyword, and generates th e passed error code
5304 * on the identifier if it is a keyword.
5305 * @param identifier the identifier to check to ensure that it is not a keywor d
5306 * @param errorCode if the passed identifier is a keyword then this error code is created on the
5307 * identifier, the error code will be one of{@link CompileTimeErrorCode#BUILT_ IN_IDENTIFIER_AS_TYPE_NAME},{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_T YPE_VARIABLE_NAME} or{@link CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPEDEF_ NAME}
5308 */
5309 void checkForBuiltInIdentifierAsName(SimpleIdentifier identifier, ErrorCode er rorCode) {
5310 Token token13 = identifier.token;
5311 if (identical(token13.type, TokenType.KEYWORD)) {
5312 _errorReporter.reportError(errorCode, identifier, [identifier.name]);
5313 }
5314 }
5315 /**
5273 * Checks to ensure that the expressions that need to be of type bool, are. Ot herwise an error is 5316 * Checks to ensure that the expressions that need to be of type bool, are. Ot herwise an error is
5274 * reported on the expression. 5317 * reported on the expression.
5275 * @see StaticTypeWarningCode#NON_BOOL_CONDITION 5318 * @see StaticTypeWarningCode#NON_BOOL_CONDITION
5276 * @param condition the conditional expression to test 5319 * @param condition the conditional expression to test
5277 */ 5320 */
5278 void checkForNonBoolCondition(Expression condition) { 5321 void checkForNonBoolCondition(Expression condition) {
5279 Type2 conditionType = getType(condition); 5322 Type2 conditionType = getType(condition);
5280 if (conditionType != null && !conditionType.isAssignableTo(_typeProvider.boo lType)) { 5323 if (conditionType != null && !conditionType.isAssignableTo(_typeProvider.boo lType)) {
5281 _errorReporter.reportError(StaticTypeWarningCode.NON_BOOL_CONDITION, condi tion, []); 5324 _errorReporter.reportError(StaticTypeWarningCode.NON_BOOL_CONDITION, condi tion, []);
5282 } 5325 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5322 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message) { 5365 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message) {
5323 this._type = type; 5366 this._type = type;
5324 this._message = message; 5367 this._message = message;
5325 } 5368 }
5326 ErrorSeverity get errorSeverity => _type.severity; 5369 ErrorSeverity get errorSeverity => _type.severity;
5327 String get message => _message; 5370 String get message => _message;
5328 ErrorType get type => _type; 5371 ErrorType get type => _type;
5329 bool needsRecompilation() => true; 5372 bool needsRecompilation() => true;
5330 String toString() => __name; 5373 String toString() => __name;
5331 } 5374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698