OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 library engine.resolver; | 3 library engine.resolver; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
8 import 'source.dart'; | 8 import 'source.dart'; |
9 import 'error.dart'; | 9 import 'error.dart'; |
10 import 'scanner.dart' as sc; | 10 import 'scanner.dart' as sc; |
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2566 Expression leftHandSide = node.leftHandSide; | 2566 Expression leftHandSide = node.leftHandSide; |
2567 if (leftHandSide != null) { | 2567 if (leftHandSide != null) { |
2568 String methodName = operatorType.lexeme; | 2568 String methodName = operatorType.lexeme; |
2569 Type2 staticType = getStaticType(leftHandSide); | 2569 Type2 staticType = getStaticType(leftHandSide); |
2570 MethodElement staticMethod = lookUpMethod(leftHandSide, staticType, meth
odName); | 2570 MethodElement staticMethod = lookUpMethod(leftHandSide, staticType, meth
odName); |
2571 node.staticElement = staticMethod; | 2571 node.staticElement = staticMethod; |
2572 Type2 propagatedType = getPropagatedType(leftHandSide); | 2572 Type2 propagatedType = getPropagatedType(leftHandSide); |
2573 MethodElement propagatedMethod = lookUpMethod(leftHandSide, propagatedTy
pe, methodName); | 2573 MethodElement propagatedMethod = lookUpMethod(leftHandSide, propagatedTy
pe, methodName); |
2574 node.propagatedElement = propagatedMethod; | 2574 node.propagatedElement = propagatedMethod; |
2575 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { | 2575 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { |
2576 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operato
r, [methodName, staticType.displayName]); | 2576 _resolver.reportErrorProxyConditionalAnalysisError3(staticType.element
, StaticTypeWarningCode.UNDEFINED_METHOD, operator, [methodName, staticType.disp
layName]); |
2577 } | 2577 } |
2578 } | 2578 } |
2579 } | 2579 } |
2580 return null; | 2580 return null; |
2581 } | 2581 } |
2582 Object visitBinaryExpression(BinaryExpression node) { | 2582 Object visitBinaryExpression(BinaryExpression node) { |
2583 sc.Token operator = node.operator; | 2583 sc.Token operator = node.operator; |
2584 if (operator.isUserDefinableOperator) { | 2584 if (operator.isUserDefinableOperator) { |
2585 Expression leftOperand = node.leftOperand; | 2585 Expression leftOperand = node.leftOperand; |
2586 if (leftOperand != null) { | 2586 if (leftOperand != null) { |
2587 String methodName = operator.lexeme; | 2587 String methodName = operator.lexeme; |
2588 Type2 staticType = getStaticType(leftOperand); | 2588 Type2 staticType = getStaticType(leftOperand); |
2589 MethodElement staticMethod = lookUpMethod(leftOperand, staticType, metho
dName); | 2589 MethodElement staticMethod = lookUpMethod(leftOperand, staticType, metho
dName); |
2590 node.staticElement = staticMethod; | 2590 node.staticElement = staticMethod; |
2591 Type2 propagatedType = getPropagatedType(leftOperand); | 2591 Type2 propagatedType = getPropagatedType(leftOperand); |
2592 MethodElement propagatedMethod = lookUpMethod(leftOperand, propagatedTyp
e, methodName); | 2592 MethodElement propagatedMethod = lookUpMethod(leftOperand, propagatedTyp
e, methodName); |
2593 node.propagatedElement = propagatedMethod; | 2593 node.propagatedElement = propagatedMethod; |
2594 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { | 2594 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode
|| propagatedType == null || shouldReportMissingMember(propagatedType, propagate
dMethod))) { |
2595 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, opera
tor, [methodName, staticType.displayName]); | 2595 _resolver.reportErrorProxyConditionalAnalysisError3(staticType.element
, StaticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.di
splayName]); |
2596 } | 2596 } |
2597 } | 2597 } |
2598 } | 2598 } |
2599 return null; | 2599 return null; |
2600 } | 2600 } |
2601 Object visitBreakStatement(BreakStatement node) { | 2601 Object visitBreakStatement(BreakStatement node) { |
2602 SimpleIdentifier labelNode = node.label; | 2602 SimpleIdentifier labelNode = node.label; |
2603 LabelElementImpl labelElement = lookupLabel(node, labelNode); | 2603 LabelElementImpl labelElement = lookupLabel(node, labelNode); |
2604 if (labelElement != null && labelElement.isOnSwitchMember) { | 2604 if (labelElement != null && labelElement.isOnSwitchMember) { |
2605 _resolver.reportError(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labe
lNode, []); | 2605 _resolver.reportError5(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, lab
elNode, []); |
2606 } | 2606 } |
2607 return null; | 2607 return null; |
2608 } | 2608 } |
2609 Object visitClassDeclaration(ClassDeclaration node) { | 2609 Object visitClassDeclaration(ClassDeclaration node) { |
2610 setMetadata(node.element, node); | 2610 setMetadata(node.element, node); |
2611 return null; | 2611 return null; |
2612 } | 2612 } |
2613 Object visitClassTypeAlias(ClassTypeAlias node) { | 2613 Object visitClassTypeAlias(ClassTypeAlias node) { |
2614 setMetadata(node.element, node); | 2614 setMetadata(node.element, node); |
2615 return null; | 2615 return null; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 setMetadata(constructorElement, node); | 2708 setMetadata(constructorElement, node); |
2709 } | 2709 } |
2710 return null; | 2710 return null; |
2711 } | 2711 } |
2712 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 2712 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
2713 SimpleIdentifier fieldName = node.fieldName; | 2713 SimpleIdentifier fieldName = node.fieldName; |
2714 ClassElement enclosingClass = _resolver.enclosingClass; | 2714 ClassElement enclosingClass = _resolver.enclosingClass; |
2715 FieldElement fieldElement = ((enclosingClass as ClassElementImpl)).getField(
fieldName.name); | 2715 FieldElement fieldElement = ((enclosingClass as ClassElementImpl)).getField(
fieldName.name); |
2716 fieldName.staticElement = fieldElement; | 2716 fieldName.staticElement = fieldElement; |
2717 if (fieldElement == null || fieldElement.isSynthetic) { | 2717 if (fieldElement == null || fieldElement.isSynthetic) { |
2718 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FI
ELD, node, [fieldName]); | 2718 _resolver.reportError5(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_F
IELD, node, [fieldName]); |
2719 } else if (fieldElement.isStatic) { | 2719 } else if (fieldElement.isStatic) { |
2720 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, n
ode, [fieldName]); | 2720 _resolver.reportError5(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD,
node, [fieldName]); |
2721 } | 2721 } |
2722 return null; | 2722 return null; |
2723 } | 2723 } |
2724 Object visitConstructorName(ConstructorName node) { | 2724 Object visitConstructorName(ConstructorName node) { |
2725 Type2 type = node.type.type; | 2725 Type2 type = node.type.type; |
2726 if (type != null && type.isDynamic) { | 2726 if (type != null && type.isDynamic) { |
2727 return null; | 2727 return null; |
2728 } else if (type is! InterfaceType) { | 2728 } else if (type is! InterfaceType) { |
2729 ASTNode parent = node.parent; | 2729 ASTNode parent = node.parent; |
2730 if (parent is InstanceCreationExpression) { | 2730 if (parent is InstanceCreationExpression) { |
(...skipping 14 matching lines...) Expand all Loading... |
2745 constructor = interfaceType.lookUpConstructor(name.name, definingLibrary); | 2745 constructor = interfaceType.lookUpConstructor(name.name, definingLibrary); |
2746 name.staticElement = constructor; | 2746 name.staticElement = constructor; |
2747 } | 2747 } |
2748 node.staticElement = constructor; | 2748 node.staticElement = constructor; |
2749 return null; | 2749 return null; |
2750 } | 2750 } |
2751 Object visitContinueStatement(ContinueStatement node) { | 2751 Object visitContinueStatement(ContinueStatement node) { |
2752 SimpleIdentifier labelNode = node.label; | 2752 SimpleIdentifier labelNode = node.label; |
2753 LabelElementImpl labelElement = lookupLabel(node, labelNode); | 2753 LabelElementImpl labelElement = lookupLabel(node, labelNode); |
2754 if (labelElement != null && labelElement.isOnSwitchStatement) { | 2754 if (labelElement != null && labelElement.isOnSwitchStatement) { |
2755 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod
e, []); | 2755 _resolver.reportError5(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNo
de, []); |
2756 } | 2756 } |
2757 return null; | 2757 return null; |
2758 } | 2758 } |
2759 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 2759 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
2760 setMetadata(node.element, node); | 2760 setMetadata(node.element, node); |
2761 return null; | 2761 return null; |
2762 } | 2762 } |
2763 Object visitExportDirective(ExportDirective node) { | 2763 Object visitExportDirective(ExportDirective node) { |
2764 Element element = node.element; | 2764 Element element = node.element; |
2765 if (element is ExportElement) { | 2765 if (element is ExportElement) { |
2766 resolveCombinators(((element as ExportElement)).exportedLibrary, node.comb
inators); | 2766 resolveCombinators(((element as ExportElement)).exportedLibrary, node.comb
inators); |
2767 setMetadata(element, node); | 2767 setMetadata(element, node); |
2768 } | 2768 } |
2769 return null; | 2769 return null; |
2770 } | 2770 } |
2771 Object visitFieldFormalParameter(FieldFormalParameter node) { | 2771 Object visitFieldFormalParameter(FieldFormalParameter node) { |
2772 String fieldName = node.identifier.name; | 2772 String fieldName = node.identifier.name; |
2773 ClassElement classElement = _resolver.enclosingClass; | 2773 ClassElement classElement = _resolver.enclosingClass; |
2774 if (classElement != null) { | 2774 if (classElement != null) { |
2775 FieldElement fieldElement = ((classElement as ClassElementImpl)).getField(
fieldName); | 2775 FieldElement fieldElement = ((classElement as ClassElementImpl)).getField(
fieldName); |
2776 if (fieldElement == null) { | 2776 if (fieldElement == null) { |
2777 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_E
XISTANT_FIELD, node, [fieldName]); | 2777 _resolver.reportError5(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_
EXISTANT_FIELD, node, [fieldName]); |
2778 } else { | 2778 } else { |
2779 ParameterElement parameterElement = node.element; | 2779 ParameterElement parameterElement = node.element; |
2780 if (parameterElement is FieldFormalParameterElementImpl) { | 2780 if (parameterElement is FieldFormalParameterElementImpl) { |
2781 FieldFormalParameterElementImpl fieldFormal = parameterElement as Fiel
dFormalParameterElementImpl; | 2781 FieldFormalParameterElementImpl fieldFormal = parameterElement as Fiel
dFormalParameterElementImpl; |
2782 fieldFormal.field = fieldElement; | 2782 fieldFormal.field = fieldElement; |
2783 Type2 declaredType = fieldFormal.type; | 2783 Type2 declaredType = fieldFormal.type; |
2784 Type2 fieldType = fieldElement.type; | 2784 Type2 fieldType = fieldElement.type; |
2785 if (node.type == null) { | 2785 if (node.type == null) { |
2786 fieldFormal.type = fieldType; | 2786 fieldFormal.type = fieldType; |
2787 } | 2787 } |
2788 if (fieldElement.isSynthetic) { | 2788 if (fieldElement.isSynthetic) { |
2789 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N
ON_EXISTANT_FIELD, node, [fieldName]); | 2789 _resolver.reportError5(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_
NON_EXISTANT_FIELD, node, [fieldName]); |
2790 } else if (fieldElement.isStatic) { | 2790 } else if (fieldElement.isStatic) { |
2791 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S
TATIC_FIELD, node, [fieldName]); | 2791 _resolver.reportError5(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_
STATIC_FIELD, node, [fieldName]); |
2792 } else if (declaredType != null && fieldType != null && !declaredType.
isAssignableTo(fieldType)) { | 2792 } else if (declaredType != null && fieldType != null && !declaredType.
isAssignableTo(fieldType)) { |
2793 _resolver.reportError(StaticWarningCode.FIELD_INITIALIZING_FORMAL_NO
T_ASSIGNABLE, node, [declaredType.displayName, fieldType.displayName]); | 2793 _resolver.reportError5(StaticWarningCode.FIELD_INITIALIZING_FORMAL_N
OT_ASSIGNABLE, node, [declaredType.displayName, fieldType.displayName]); |
2794 } | 2794 } |
2795 } else { | 2795 } else { |
2796 if (fieldElement.isSynthetic) { | 2796 if (fieldElement.isSynthetic) { |
2797 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N
ON_EXISTANT_FIELD, node, [fieldName]); | 2797 _resolver.reportError5(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_
NON_EXISTANT_FIELD, node, [fieldName]); |
2798 } else if (fieldElement.isStatic) { | 2798 } else if (fieldElement.isStatic) { |
2799 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S
TATIC_FIELD, node, [fieldName]); | 2799 _resolver.reportError5(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_
STATIC_FIELD, node, [fieldName]); |
2800 } | 2800 } |
2801 } | 2801 } |
2802 } | 2802 } |
2803 } | 2803 } |
2804 return super.visitFieldFormalParameter(node); | 2804 return super.visitFieldFormalParameter(node); |
2805 } | 2805 } |
2806 Object visitFunctionDeclaration(FunctionDeclaration node) { | 2806 Object visitFunctionDeclaration(FunctionDeclaration node) { |
2807 setMetadata(node.element, node); | 2807 setMetadata(node.element, node); |
2808 return null; | 2808 return null; |
2809 } | 2809 } |
(...skipping 21 matching lines...) Expand all Loading... |
2831 resolveCombinators(library, node.combinators); | 2831 resolveCombinators(library, node.combinators); |
2832 } | 2832 } |
2833 setMetadata(element, node); | 2833 setMetadata(element, node); |
2834 } | 2834 } |
2835 return null; | 2835 return null; |
2836 } | 2836 } |
2837 Object visitIndexExpression(IndexExpression node) { | 2837 Object visitIndexExpression(IndexExpression node) { |
2838 Expression target = node.realTarget; | 2838 Expression target = node.realTarget; |
2839 Type2 staticType = getStaticType(target); | 2839 Type2 staticType = getStaticType(target); |
2840 Type2 propagatedType = getPropagatedType(target); | 2840 Type2 propagatedType = getPropagatedType(target); |
2841 if (node.inGetterContext()) { | 2841 String getterMethodName = sc.TokenType.INDEX.lexeme; |
2842 String methodName = sc.TokenType.INDEX.lexeme; | 2842 String setterMethodName = sc.TokenType.INDEX_EQ.lexeme; |
2843 bool error = lookUpCheckIndexOperator(node, target, methodName, staticType
, propagatedType); | 2843 bool isInGetterContext = node.inGetterContext(); |
2844 if (error) { | 2844 bool isInSetterContext = node.inSetterContext(); |
2845 return null; | 2845 if (isInGetterContext && isInSetterContext) { |
2846 } | 2846 MethodElement setterStaticMethod = lookUpMethod(target, staticType, setter
MethodName); |
2847 } | 2847 MethodElement setterPropagatedMethod = lookUpMethod(target, propagatedType
, setterMethodName); |
2848 if (node.inSetterContext()) { | 2848 node.staticElement = setterStaticMethod; |
2849 String methodName = sc.TokenType.INDEX_EQ.lexeme; | 2849 node.propagatedElement = setterPropagatedMethod; |
2850 lookUpCheckIndexOperator(node, target, methodName, staticType, propagatedT
ype); | 2850 checkForUndefinedIndexOperator(node, target, getterMethodName, setterStati
cMethod, setterPropagatedMethod, staticType, propagatedType); |
| 2851 MethodElement getterStaticMethod = lookUpMethod(target, staticType, getter
MethodName); |
| 2852 MethodElement getterPropagatedMethod = lookUpMethod(target, propagatedType
, getterMethodName); |
| 2853 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(getterStaticMe
thod, getterPropagatedMethod); |
| 2854 node.auxiliaryElements = auxiliaryElements; |
| 2855 checkForUndefinedIndexOperator(node, target, getterMethodName, getterStati
cMethod, getterPropagatedMethod, staticType, propagatedType); |
| 2856 } else if (isInGetterContext) { |
| 2857 MethodElement staticMethod = lookUpMethod(target, staticType, getterMethod
Name); |
| 2858 MethodElement propagatedMethod = lookUpMethod(target, propagatedType, gett
erMethodName); |
| 2859 node.staticElement = staticMethod; |
| 2860 node.propagatedElement = propagatedMethod; |
| 2861 checkForUndefinedIndexOperator(node, target, getterMethodName, staticMetho
d, propagatedMethod, staticType, propagatedType); |
| 2862 } else if (isInSetterContext) { |
| 2863 MethodElement staticMethod = lookUpMethod(target, staticType, setterMethod
Name); |
| 2864 MethodElement propagatedMethod = lookUpMethod(target, propagatedType, sett
erMethodName); |
| 2865 node.staticElement = staticMethod; |
| 2866 node.propagatedElement = propagatedMethod; |
| 2867 checkForUndefinedIndexOperator(node, target, setterMethodName, staticMetho
d, propagatedMethod, staticType, propagatedType); |
2851 } | 2868 } |
2852 return null; | 2869 return null; |
2853 } | 2870 } |
2854 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 2871 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
2855 ConstructorElement invokedConstructor = node.constructorName.staticElement; | 2872 ConstructorElement invokedConstructor = node.constructorName.staticElement; |
2856 node.staticElement = invokedConstructor; | 2873 node.staticElement = invokedConstructor; |
2857 ArgumentList argumentList = node.argumentList; | 2874 ArgumentList argumentList = node.argumentList; |
2858 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons
t, argumentList, invokedConstructor); | 2875 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons
t, argumentList, invokedConstructor); |
2859 if (parameters != null) { | 2876 if (parameters != null) { |
2860 argumentList.correspondingStaticParameters = parameters; | 2877 argumentList.correspondingStaticParameters = parameters; |
2861 } | 2878 } |
2862 return null; | 2879 return null; |
2863 } | 2880 } |
2864 Object visitLibraryDirective(LibraryDirective node) { | 2881 Object visitLibraryDirective(LibraryDirective node) { |
2865 setMetadata(node.element, node); | 2882 setMetadata(node.element, node); |
2866 return null; | 2883 return null; |
2867 } | 2884 } |
2868 Object visitMethodDeclaration(MethodDeclaration node) { | 2885 Object visitMethodDeclaration(MethodDeclaration node) { |
2869 setMetadata(node.element, node); | 2886 setMetadata(node.element, node); |
2870 return null; | 2887 return null; |
2871 } | 2888 } |
2872 Object visitMethodInvocation(MethodInvocation node) { | 2889 Object visitMethodInvocation(MethodInvocation node) { |
2873 SimpleIdentifier methodName = node.methodName; | 2890 SimpleIdentifier methodName = node.methodName; |
2874 Expression target = node.realTarget; | 2891 Expression target = node.realTarget; |
2875 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { | 2892 if (target is SuperExpression && !isSuperInValidContext(target as SuperExpre
ssion)) { |
2876 return null; | 2893 return null; |
2877 } | 2894 } |
2878 Element staticElement; | 2895 Element staticElement; |
2879 Element propagatedElement; | 2896 Element propagatedElement; |
2880 if (target == null) { | 2897 if (target == null) { |
2881 staticElement = resolveInvokedElement2(methodName); | 2898 staticElement = resolveInvokedElement2(methodName); |
2882 propagatedElement = null; | 2899 propagatedElement = null; |
2883 } else { | 2900 } else { |
2884 staticElement = resolveInvokedElement(target, getStaticType(target), metho
dName); | 2901 staticElement = resolveInvokedElement(target, getStaticType(target), metho
dName); |
2885 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); | 2902 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); |
(...skipping 10 matching lines...) Expand all Loading... |
2896 } | 2913 } |
2897 } | 2914 } |
2898 if (propagatedElement != null) { | 2915 if (propagatedElement != null) { |
2899 List<ParameterElement> parameters = computeCorrespondingParameters(argumen
tList, propagatedElement); | 2916 List<ParameterElement> parameters = computeCorrespondingParameters(argumen
tList, propagatedElement); |
2900 if (parameters != null) { | 2917 if (parameters != null) { |
2901 argumentList.correspondingPropagatedParameters = parameters; | 2918 argumentList.correspondingPropagatedParameters = parameters; |
2902 } | 2919 } |
2903 } | 2920 } |
2904 ErrorCode errorCode = checkForInvocationError(target, staticElement); | 2921 ErrorCode errorCode = checkForInvocationError(target, staticElement); |
2905 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION))
{ | 2922 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION))
{ |
2906 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, me
thodName, [methodName.name]); | 2923 _resolver.reportError5(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, m
ethodName, [methodName.name]); |
2907 } else if (identical(errorCode, CompileTimeErrorCode.UNDEFINED_FUNCTION)) { | 2924 } else if (identical(errorCode, CompileTimeErrorCode.UNDEFINED_FUNCTION)) { |
2908 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_FUNCTION, methodName,
[methodName.name]); | 2925 _resolver.reportError5(CompileTimeErrorCode.UNDEFINED_FUNCTION, methodName
, [methodName.name]); |
2909 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { | 2926 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { |
2910 String targetTypeName; | 2927 String targetTypeName; |
2911 if (target == null) { | 2928 if (target == null) { |
2912 ClassElement enclosingClass = _resolver.enclosingClass; | 2929 ClassElement enclosingClass = _resolver.enclosingClass; |
2913 targetTypeName = enclosingClass.displayName; | 2930 targetTypeName = enclosingClass.displayName; |
| 2931 _resolver.reportErrorProxyConditionalAnalysisError(_resolver.enclosingCl
ass, StaticTypeWarningCode.UNDEFINED_METHOD, methodName, [methodName.name, targe
tTypeName]); |
2914 } else { | 2932 } else { |
2915 Type2 targetType = getStaticType(target); | 2933 Type2 targetType = getStaticType(target); |
2916 if (targetType != null && targetType.isDartCoreFunction && methodName.na
me == CALL_METHOD_NAME) { | 2934 if (targetType != null && targetType.isDartCoreFunction && methodName.na
me == CALL_METHOD_NAME) { |
2917 return null; | 2935 return null; |
2918 } | 2936 } |
2919 targetTypeName = targetType == null ? null : targetType.displayName; | 2937 targetTypeName = targetType == null ? null : targetType.displayName; |
| 2938 _resolver.reportErrorProxyConditionalAnalysisError(targetType.element, S
taticTypeWarningCode.UNDEFINED_METHOD, methodName, [methodName.name, targetTypeN
ame]); |
2920 } | 2939 } |
2921 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_METHOD, methodName,
[methodName.name, targetTypeName]); | |
2922 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { | 2940 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD
)) { |
2923 Type2 targetType = getPropagatedType(target); | 2941 Type2 targetType = getPropagatedType(target); |
2924 if (targetType == null) { | 2942 if (targetType == null) { |
2925 targetType = getStaticType(target); | 2943 targetType = getStaticType(target); |
2926 } | 2944 } |
2927 String targetTypeName = targetType == null ? null : targetType.name; | 2945 String targetTypeName = targetType == null ? null : targetType.name; |
2928 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, method
Name, [methodName.name, targetTypeName]); | 2946 _resolver.reportError5(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, metho
dName, [methodName.name, targetTypeName]); |
2929 } | 2947 } |
2930 return null; | 2948 return null; |
2931 } | 2949 } |
2932 Object visitPartDirective(PartDirective node) { | 2950 Object visitPartDirective(PartDirective node) { |
2933 setMetadata(node.element, node); | 2951 setMetadata(node.element, node); |
2934 return null; | 2952 return null; |
2935 } | 2953 } |
2936 Object visitPartOfDirective(PartOfDirective node) { | 2954 Object visitPartOfDirective(PartOfDirective node) { |
2937 setMetadata(node.element, node); | 2955 setMetadata(node.element, node); |
2938 return null; | 2956 return null; |
2939 } | 2957 } |
2940 Object visitPostfixExpression(PostfixExpression node) { | 2958 Object visitPostfixExpression(PostfixExpression node) { |
2941 Expression operand = node.operand; | 2959 Expression operand = node.operand; |
2942 String methodName = getPostfixOperator(node); | 2960 String methodName = getPostfixOperator(node); |
2943 Type2 staticType = getStaticType(operand); | 2961 Type2 staticType = getStaticType(operand); |
2944 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName); | 2962 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName); |
2945 node.staticElement = staticMethod; | 2963 node.staticElement = staticMethod; |
2946 Type2 propagatedType = getPropagatedType(operand); | 2964 Type2 propagatedType = getPropagatedType(operand); |
2947 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, metho
dName); | 2965 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, metho
dName); |
2948 node.propagatedElement = propagatedMethod; | 2966 node.propagatedElement = propagatedMethod; |
2949 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { | 2967 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { |
2950 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, node.oper
ator, [methodName, staticType.displayName]); | 2968 _resolver.reportErrorProxyConditionalAnalysisError3(staticType.element, St
aticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.d
isplayName]); |
2951 } | 2969 } |
2952 return null; | 2970 return null; |
2953 } | 2971 } |
2954 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 2972 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
2955 SimpleIdentifier prefix = node.prefix; | 2973 SimpleIdentifier prefix = node.prefix; |
2956 SimpleIdentifier identifier = node.identifier; | 2974 SimpleIdentifier identifier = node.identifier; |
2957 Element prefixElement = prefix.staticElement; | 2975 Element prefixElement = prefix.staticElement; |
2958 if (prefixElement is PrefixElement) { | 2976 if (prefixElement is PrefixElement) { |
2959 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibra
ry); | 2977 Element element = _resolver.nameScope.lookup(node, _resolver.definingLibra
ry); |
2960 if (element == null && identifier.inSetterContext()) { | 2978 if (element == null && identifier.inSetterContext()) { |
2961 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdenti
fier("${node.name}="), _resolver.definingLibrary); | 2979 element = _resolver.nameScope.lookup(new ElementResolver_SyntheticIdenti
fier("${node.name}="), _resolver.definingLibrary); |
2962 } | 2980 } |
2963 if (element == null) { | 2981 if (element == null) { |
2964 if (identifier.inSetterContext()) { | 2982 if (identifier.inSetterContext()) { |
2965 _resolver.reportError(StaticWarningCode.UNDEFINED_SETTER, identifier,
[identifier.name, prefixElement.name]); | 2983 _resolver.reportError5(StaticWarningCode.UNDEFINED_SETTER, identifier,
[identifier.name, prefixElement.name]); |
2966 } else { | 2984 } else { |
2967 _resolver.reportError(StaticWarningCode.UNDEFINED_GETTER, identifier,
[identifier.name, prefixElement.name]); | 2985 _resolver.reportError5(StaticWarningCode.UNDEFINED_GETTER, identifier,
[identifier.name, prefixElement.name]); |
2968 } | 2986 } |
2969 return null; | 2987 return null; |
2970 } | 2988 } |
2971 if (element is PropertyAccessorElement && identifier.inSetterContext()) { | 2989 if (element is PropertyAccessorElement && identifier.inSetterContext()) { |
2972 PropertyInducingElement variable = ((element as PropertyAccessorElement)
).variable; | 2990 PropertyInducingElement variable = ((element as PropertyAccessorElement)
).variable; |
2973 if (variable != null) { | 2991 if (variable != null) { |
2974 PropertyAccessorElement setter = variable.setter; | 2992 PropertyAccessorElement setter = variable.setter; |
2975 if (setter != null) { | 2993 if (setter != null) { |
2976 element = setter; | 2994 element = setter; |
2977 } | 2995 } |
(...skipping 20 matching lines...) Expand all Loading... |
2998 if (operatorType.isUserDefinableOperator || identical(operatorType, sc.Token
Type.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { | 3016 if (operatorType.isUserDefinableOperator || identical(operatorType, sc.Token
Type.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { |
2999 Expression operand = node.operand; | 3017 Expression operand = node.operand; |
3000 String methodName = getPrefixOperator(node); | 3018 String methodName = getPrefixOperator(node); |
3001 Type2 staticType = getStaticType(operand); | 3019 Type2 staticType = getStaticType(operand); |
3002 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName)
; | 3020 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName)
; |
3003 node.staticElement = staticMethod; | 3021 node.staticElement = staticMethod; |
3004 Type2 propagatedType = getPropagatedType(operand); | 3022 Type2 propagatedType = getPropagatedType(operand); |
3005 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, met
hodName); | 3023 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, met
hodName); |
3006 node.propagatedElement = propagatedMethod; | 3024 node.propagatedElement = propagatedMethod; |
3007 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM
ethod))) { | 3025 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM
ethod))) { |
3008 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operato
r, [methodName, staticType.displayName]); | 3026 _resolver.reportErrorProxyConditionalAnalysisError3(staticType.element,
StaticTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.disp
layName]); |
3009 } | 3027 } |
3010 } | 3028 } |
3011 return null; | 3029 return null; |
3012 } | 3030 } |
3013 Object visitPropertyAccess(PropertyAccess node) { | 3031 Object visitPropertyAccess(PropertyAccess node) { |
3014 Expression target = node.realTarget; | 3032 Expression target = node.realTarget; |
3015 if (target is SuperExpression && !isSuperInValidContext((target as SuperExpr
ession))) { | 3033 if (target is SuperExpression && !isSuperInValidContext(target as SuperExpre
ssion)) { |
3016 return null; | 3034 return null; |
3017 } | 3035 } |
3018 SimpleIdentifier propertyName = node.propertyName; | 3036 SimpleIdentifier propertyName = node.propertyName; |
3019 resolvePropertyAccess(target, propertyName); | 3037 resolvePropertyAccess(target, propertyName); |
3020 return null; | 3038 return null; |
3021 } | 3039 } |
3022 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 3040 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
3023 ClassElement enclosingClass = _resolver.enclosingClass; | 3041 ClassElement enclosingClass = _resolver.enclosingClass; |
3024 if (enclosingClass == null) { | 3042 if (enclosingClass == null) { |
3025 return null; | 3043 return null; |
(...skipping 23 matching lines...) Expand all Loading... |
3049 Object visitSimpleIdentifier(SimpleIdentifier node) { | 3067 Object visitSimpleIdentifier(SimpleIdentifier node) { |
3050 if (node.staticElement != null) { | 3068 if (node.staticElement != null) { |
3051 return null; | 3069 return null; |
3052 } | 3070 } |
3053 if (node.name == _dynamicType.name) { | 3071 if (node.name == _dynamicType.name) { |
3054 node.staticElement = _dynamicType.element; | 3072 node.staticElement = _dynamicType.element; |
3055 node.staticType = _typeType; | 3073 node.staticType = _typeType; |
3056 return null; | 3074 return null; |
3057 } | 3075 } |
3058 Element element = resolveSimpleIdentifier(node); | 3076 Element element = resolveSimpleIdentifier(node); |
3059 if (isFactoryConstructorReturnType(node) && element != _resolver.enclosingCl
ass) { | 3077 ClassElement enclosingClass = _resolver.enclosingClass; |
3060 _resolver.reportError(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLAS
S, node, []); | 3078 if (isFactoryConstructorReturnType(node) && element != enclosingClass) { |
3061 } else if (isConstructorReturnType(node) && element != _resolver.enclosingCl
ass) { | 3079 _resolver.reportError5(CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLA
SS, node, []); |
3062 _resolver.reportError(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node,
[]); | 3080 } else if (isConstructorReturnType(node) && element != enclosingClass) { |
| 3081 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node
, []); |
3063 element = null; | 3082 element = null; |
3064 } else if (element == null || (element is PrefixElement && !isValidAsPrefix(
node))) { | 3083 } else if (element == null || (element is PrefixElement && !isValidAsPrefix(
node))) { |
3065 if (isConstructorReturnType(node)) { | 3084 if (isConstructorReturnType(node)) { |
3066 _resolver.reportError(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, nod
e, []); | 3085 _resolver.reportError5(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, no
de, []); |
3067 } else { | 3086 } else { |
3068 _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, node, [nod
e.name]); | 3087 _resolver.reportErrorProxyConditionalAnalysisError(_resolver.enclosingCl
ass, StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]); |
3069 } | 3088 } |
3070 } | 3089 } |
3071 node.staticElement = element; | 3090 node.staticElement = element; |
| 3091 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { |
| 3092 InterfaceType enclosingType = enclosingClass.type; |
| 3093 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(lookUpGetter(n
ull, enclosingType, node.name), null); |
| 3094 node.auxiliaryElements = auxiliaryElements; |
| 3095 } |
3072 if (node.parent is Annotation) { | 3096 if (node.parent is Annotation) { |
3073 Annotation annotation = node.parent as Annotation; | 3097 Annotation annotation = node.parent as Annotation; |
3074 resolveAnnotationElement(annotation, element, null); | 3098 resolveAnnotationElement(annotation, element, null); |
3075 } | 3099 } |
3076 return null; | 3100 return null; |
3077 } | 3101 } |
3078 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 3102 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
3079 ClassElement enclosingClass = _resolver.enclosingClass; | 3103 ClassElement enclosingClass = _resolver.enclosingClass; |
3080 if (enclosingClass == null) { | 3104 if (enclosingClass == null) { |
3081 return null; | 3105 return null; |
3082 } | 3106 } |
3083 ClassElement superclass = getSuperclass(enclosingClass); | 3107 ClassElement superclass = getSuperclass(enclosingClass); |
3084 if (superclass == null) { | 3108 if (superclass == null) { |
3085 return null; | 3109 return null; |
3086 } | 3110 } |
3087 SimpleIdentifier name = node.constructorName; | 3111 SimpleIdentifier name = node.constructorName; |
3088 ConstructorElement element; | 3112 ConstructorElement element; |
3089 if (name == null) { | 3113 if (name == null) { |
3090 element = superclass.unnamedConstructor; | 3114 element = superclass.unnamedConstructor; |
3091 } else { | 3115 } else { |
3092 element = superclass.getNamedConstructor(name.name); | 3116 element = superclass.getNamedConstructor(name.name); |
3093 } | 3117 } |
3094 if (element == null) { | 3118 if (element == null) { |
3095 if (name != null) { | 3119 if (name != null) { |
3096 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER, node, [superclass.name, name]); | 3120 _resolver.reportError5(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INI
TIALIZER, node, [superclass.name, name]); |
3097 } else { | 3121 } else { |
3098 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT
IALIZER_DEFAULT, node, [superclass.name]); | 3122 _resolver.reportError5(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INI
TIALIZER_DEFAULT, node, [superclass.name]); |
3099 } | 3123 } |
3100 return null; | 3124 return null; |
3101 } else { | 3125 } else { |
3102 if (element.isFactory) { | 3126 if (element.isFactory) { |
3103 _resolver.reportError(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, n
ode, [element]); | 3127 _resolver.reportError5(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR,
node, [element]); |
3104 } | 3128 } |
3105 } | 3129 } |
3106 if (name != null) { | 3130 if (name != null) { |
3107 name.staticElement = element; | 3131 name.staticElement = element; |
3108 } | 3132 } |
3109 node.staticElement = element; | 3133 node.staticElement = element; |
3110 node.element = element; | 3134 node.element = element; |
3111 ArgumentList argumentList = node.argumentList; | 3135 ArgumentList argumentList = node.argumentList; |
3112 List<ParameterElement> parameters = resolveArgumentsToParameters(isInConstCo
nstructor, argumentList, element); | 3136 List<ParameterElement> parameters = resolveArgumentsToParameters(isInConstCo
nstructor, argumentList, element); |
3113 if (parameters != null) { | 3137 if (parameters != null) { |
3114 argumentList.correspondingStaticParameters = parameters; | 3138 argumentList.correspondingStaticParameters = parameters; |
3115 } | 3139 } |
3116 return null; | 3140 return null; |
3117 } | 3141 } |
3118 Object visitSuperExpression(SuperExpression node) { | 3142 Object visitSuperExpression(SuperExpression node) { |
3119 if (!isSuperInValidContext(node)) { | 3143 if (!isSuperInValidContext(node)) { |
3120 _resolver.reportError(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT, node,
[]); | 3144 _resolver.reportError5(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT, node
, []); |
3121 } | 3145 } |
3122 return super.visitSuperExpression(node); | 3146 return super.visitSuperExpression(node); |
3123 } | 3147 } |
3124 Object visitTypeParameter(TypeParameter node) { | 3148 Object visitTypeParameter(TypeParameter node) { |
3125 TypeName bound = node.bound; | 3149 TypeName bound = node.bound; |
3126 if (bound != null) { | 3150 if (bound != null) { |
3127 TypeVariableElementImpl variable = node.name.staticElement as TypeVariable
ElementImpl; | 3151 TypeVariableElementImpl variable = node.name.staticElement as TypeVariable
ElementImpl; |
3128 if (variable != null) { | 3152 if (variable != null) { |
3129 variable.bound = bound.type; | 3153 variable.bound = bound.type; |
3130 } | 3154 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3188 } | 3212 } |
3189 } | 3213 } |
3190 } else if (element is VariableElement) { | 3214 } else if (element is VariableElement) { |
3191 Type2 variableType = ((element as VariableElement)).type; | 3215 Type2 variableType = ((element as VariableElement)).type; |
3192 if (!isExecutableType(variableType)) { | 3216 if (!isExecutableType(variableType)) { |
3193 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 3217 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
3194 } | 3218 } |
3195 } else { | 3219 } else { |
3196 if (target == null) { | 3220 if (target == null) { |
3197 ClassElement enclosingClass = _resolver.enclosingClass; | 3221 ClassElement enclosingClass = _resolver.enclosingClass; |
3198 if (element == null) { | 3222 if (enclosingClass == null) { |
3199 if (enclosingClass == null) { | 3223 return CompileTimeErrorCode.UNDEFINED_FUNCTION; |
3200 return CompileTimeErrorCode.UNDEFINED_FUNCTION; | 3224 } else if (element == null) { |
3201 } else { | 3225 return StaticTypeWarningCode.UNDEFINED_METHOD; |
3202 return StaticTypeWarningCode.UNDEFINED_METHOD; | |
3203 } | |
3204 } else { | 3226 } else { |
3205 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; | 3227 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; |
3206 } | 3228 } |
3207 } else { | 3229 } else { |
3208 Type2 targetType = getStaticType(target); | 3230 Type2 targetType = getStaticType(target); |
3209 if (targetType == null) { | 3231 if (targetType == null) { |
3210 return CompileTimeErrorCode.UNDEFINED_FUNCTION; | 3232 return CompileTimeErrorCode.UNDEFINED_FUNCTION; |
3211 } else if (!targetType.isDynamic) { | 3233 } else if (!targetType.isDynamic) { |
3212 return StaticTypeWarningCode.UNDEFINED_METHOD; | 3234 return StaticTypeWarningCode.UNDEFINED_METHOD; |
3213 } | 3235 } |
3214 } | 3236 } |
3215 } | 3237 } |
3216 } | 3238 } |
3217 return null; | 3239 return null; |
3218 } | 3240 } |
3219 | 3241 |
3220 /** | 3242 /** |
| 3243 * Check that the for some index expression that the method element was resolv
ed, otherwise a |
| 3244 * [StaticWarningCode#UNDEFINED_OPERATOR] is generated. |
| 3245 * |
| 3246 * @param node the index expression to resolve |
| 3247 * @param target the target of the expression |
| 3248 * @param methodName the name of the operator associated with the context of u
sing of the given |
| 3249 * index expression |
| 3250 * @return `true` if and only if an error code is generated on the passed node |
| 3251 */ |
| 3252 bool checkForUndefinedIndexOperator(IndexExpression node, Expression target, S
tring methodName, MethodElement staticMethod, MethodElement propagatedMethod, Ty
pe2 staticType, Type2 propagatedType) { |
| 3253 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { |
| 3254 sc.Token leftBracket = node.leftBracket; |
| 3255 sc.Token rightBracket = node.rightBracket; |
| 3256 if (leftBracket == null || rightBracket == null) { |
| 3257 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, S
taticTypeWarningCode.UNDEFINED_OPERATOR, node, [methodName, staticType.displayNa
me]); |
| 3258 } else { |
| 3259 int offset = leftBracket.offset; |
| 3260 int length = rightBracket.offset - offset + 1; |
| 3261 _resolver.reportErrorProxyConditionalAnalysisError2(staticType.element,
StaticTypeWarningCode.UNDEFINED_OPERATOR, offset, length, [methodName, staticTyp
e.displayName]); |
| 3262 } |
| 3263 return true; |
| 3264 } |
| 3265 return false; |
| 3266 } |
| 3267 |
| 3268 /** |
3221 * Given a list of arguments and the element that will be invoked using those
argument, compute | 3269 * Given a list of arguments and the element that will be invoked using those
argument, compute |
3222 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 3270 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
3223 * correspond to the arguments, or `null` if no correspondence could be comput
ed. | 3271 * correspond to the arguments, or `null` if no correspondence could be comput
ed. |
3224 * | 3272 * |
3225 * @param argumentList the list of arguments being passed to the element | 3273 * @param argumentList the list of arguments being passed to the element |
3226 * @param executableElement the element that will be invoked with the argument
s | 3274 * @param executableElement the element that will be invoked with the argument
s |
3227 * @return the parameters that correspond to the arguments | 3275 * @return the parameters that correspond to the arguments |
3228 */ | 3276 */ |
3229 List<ParameterElement> computeCorrespondingParameters(ArgumentList argumentLis
t, Element element2) { | 3277 List<ParameterElement> computeCorrespondingParameters(ArgumentList argumentLis
t, Element element2) { |
3230 if (element2 is PropertyAccessorElement) { | 3278 if (element2 is PropertyAccessorElement) { |
3231 FunctionType getterType = ((element2 as PropertyAccessorElement)).type; | 3279 FunctionType getterType = ((element2 as PropertyAccessorElement)).type; |
3232 if (getterType != null) { | 3280 if (getterType != null) { |
3233 Type2 getterReturnType = getterType.returnType; | 3281 Type2 getterReturnType = getterType.returnType; |
3234 if (getterReturnType is InterfaceType) { | 3282 if (getterReturnType is InterfaceType) { |
3235 MethodElement callMethod = ((getterReturnType as InterfaceType)).lookU
pMethod(CALL_METHOD_NAME, _resolver.definingLibrary); | 3283 MethodElement callMethod = ((getterReturnType as InterfaceType)).lookU
pMethod(CALL_METHOD_NAME, _resolver.definingLibrary); |
3236 if (callMethod != null) { | 3284 if (callMethod != null) { |
3237 return resolveArgumentsToParameters(false, argumentList, callMethod)
; | 3285 return resolveArgumentsToParameters(false, argumentList, callMethod)
; |
3238 } | 3286 } |
3239 } else if (getterReturnType is FunctionType) { | 3287 } else if (getterReturnType is FunctionType) { |
3240 Element functionElement = ((getterReturnType as FunctionType)).element
; | 3288 Element functionElement = ((getterReturnType as FunctionType)).element
; |
3241 if (functionElement is ExecutableElement) { | 3289 if (functionElement is ExecutableElement) { |
3242 return resolveArgumentsToParameters(false, argumentList, (functionEl
ement as ExecutableElement)); | 3290 return resolveArgumentsToParameters(false, argumentList, functionEle
ment as ExecutableElement); |
3243 } | 3291 } |
3244 } | 3292 } |
3245 } | 3293 } |
3246 } else if (element2 is ExecutableElement) { | 3294 } else if (element2 is ExecutableElement) { |
3247 return resolveArgumentsToParameters(false, argumentList, (element2 as Exec
utableElement)); | 3295 return resolveArgumentsToParameters(false, argumentList, element2 as Execu
tableElement); |
3248 } else if (element2 is VariableElement) { | 3296 } else if (element2 is VariableElement) { |
3249 VariableElement variable = element2 as VariableElement; | 3297 VariableElement variable = element2 as VariableElement; |
3250 Type2 type = variable.type; | 3298 Type2 type = variable.type; |
3251 if (type is FunctionType) { | 3299 if (type is FunctionType) { |
3252 FunctionType functionType = type as FunctionType; | 3300 FunctionType functionType = type as FunctionType; |
3253 List<ParameterElement> parameters = functionType.parameters; | 3301 List<ParameterElement> parameters = functionType.parameters; |
3254 return resolveArgumentsToParameters2(false, argumentList, parameters); | 3302 return resolveArgumentsToParameters2(false, argumentList, parameters); |
3255 } else if (type is InterfaceType) { | 3303 } else if (type is InterfaceType) { |
3256 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(CALL_M
ETHOD_NAME, _resolver.definingLibrary); | 3304 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(CALL_M
ETHOD_NAME, _resolver.definingLibrary); |
3257 if (callMethod != null) { | 3305 if (callMethod != null) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3438 return identical(((parent as ImportDirective)).prefix, node); | 3486 return identical(((parent as ImportDirective)).prefix, node); |
3439 } else if (parent is PrefixedIdentifier) { | 3487 } else if (parent is PrefixedIdentifier) { |
3440 return true; | 3488 return true; |
3441 } else if (parent is MethodInvocation) { | 3489 } else if (parent is MethodInvocation) { |
3442 return identical(((parent as MethodInvocation)).target, node); | 3490 return identical(((parent as MethodInvocation)).target, node); |
3443 } | 3491 } |
3444 return false; | 3492 return false; |
3445 } | 3493 } |
3446 | 3494 |
3447 /** | 3495 /** |
3448 * Looks up the method element with the given name for index expression, repor
ts | |
3449 * [StaticWarningCode#UNDEFINED_OPERATOR] if not found. | |
3450 * | |
3451 * @param node the index expression to resolve | |
3452 * @param target the target of the expression | |
3453 * @param methodName the name of the operator associated with the context of u
sing of the given | |
3454 * index expression | |
3455 * @return `true` if and only if an error code is generated on the passed node | |
3456 */ | |
3457 bool lookUpCheckIndexOperator(IndexExpression node, Expression target, String
methodName, Type2 staticType, Type2 propagatedType) { | |
3458 MethodElement staticMethod = lookUpMethod(target, staticType, methodName); | |
3459 MethodElement propagatedMethod = lookUpMethod(target, propagatedType, method
Name); | |
3460 node.staticElement = staticMethod; | |
3461 node.propagatedElement = propagatedMethod; | |
3462 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || p
ropagatedType == null || shouldReportMissingMember(propagatedType, propagatedMet
hod))) { | |
3463 sc.Token leftBracket = node.leftBracket; | |
3464 sc.Token rightBracket = node.rightBracket; | |
3465 if (leftBracket == null || rightBracket == null) { | |
3466 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_OPERATOR, node, [m
ethodName, staticType.displayName]); | |
3467 return true; | |
3468 } else { | |
3469 int offset = leftBracket.offset; | |
3470 int length = rightBracket.offset - offset + 1; | |
3471 _resolver.reportError5(StaticTypeWarningCode.UNDEFINED_OPERATOR, offset,
length, [methodName, staticType.displayName]); | |
3472 return true; | |
3473 } | |
3474 } | |
3475 return false; | |
3476 } | |
3477 | |
3478 /** | |
3479 * Look up the getter with the given name in the given type. Return the elemen
t representing the | 3496 * Look up the getter with the given name in the given type. Return the elemen
t representing the |
3480 * getter that was found, or `null` if there is no getter with the given name. | 3497 * getter that was found, or `null` if there is no getter with the given name. |
3481 * | 3498 * |
3482 * @param target the target of the invocation, or `null` if there is no target | 3499 * @param target the target of the invocation, or `null` if there is no target |
3483 * @param type the type in which the getter is defined | 3500 * @param type the type in which the getter is defined |
3484 * @param getterName the name of the getter being looked up | 3501 * @param getterName the name of the getter being looked up |
3485 * @return the element representing the getter that was found | 3502 * @return the element representing the getter that was found |
3486 */ | 3503 */ |
3487 PropertyAccessorElement lookUpGetter(Expression target, Type2 type, String get
terName) { | 3504 PropertyAccessorElement lookUpGetter(Expression target, Type2 type, String get
terName) { |
3488 type = resolveTypeVariable(type); | 3505 type = resolveTypeVariable(type); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3631 if (labelNode == null) { | 3648 if (labelNode == null) { |
3632 if (labelScope == null) { | 3649 if (labelScope == null) { |
3633 } else { | 3650 } else { |
3634 labelElement = labelScope.lookup2(LabelScope.EMPTY_LABEL) as LabelElemen
tImpl; | 3651 labelElement = labelScope.lookup2(LabelScope.EMPTY_LABEL) as LabelElemen
tImpl; |
3635 if (labelElement == null) { | 3652 if (labelElement == null) { |
3636 } | 3653 } |
3637 labelElement = null; | 3654 labelElement = null; |
3638 } | 3655 } |
3639 } else { | 3656 } else { |
3640 if (labelScope == null) { | 3657 if (labelScope == null) { |
3641 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode, [
labelNode.name]); | 3658 _resolver.reportError5(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode,
[labelNode.name]); |
3642 } else { | 3659 } else { |
3643 labelElement = labelScope.lookup(labelNode) as LabelElementImpl; | 3660 labelElement = labelScope.lookup(labelNode) as LabelElementImpl; |
3644 if (labelElement == null) { | 3661 if (labelElement == null) { |
3645 _resolver.reportError(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode,
[labelNode.name]); | 3662 _resolver.reportError5(CompileTimeErrorCode.LABEL_UNDEFINED, labelNode
, [labelNode.name]); |
3646 } else { | 3663 } else { |
3647 labelNode.staticElement = labelElement; | 3664 labelNode.staticElement = labelElement; |
3648 } | 3665 } |
3649 } | 3666 } |
3650 } | 3667 } |
3651 if (labelElement != null) { | 3668 if (labelElement != null) { |
3652 ExecutableElement labelContainer = labelElement.getAncestor(ExecutableElem
ent); | 3669 ExecutableElement labelContainer = labelElement.getAncestor(ExecutableElem
ent); |
3653 if (labelContainer != _resolver.enclosingFunction) { | 3670 if (labelContainer != _resolver.enclosingFunction) { |
3654 _resolver.reportError(CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, labelNo
de, [labelNode.name]); | 3671 _resolver.reportError5(CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, labelN
ode, [labelNode.name]); |
3655 labelElement = null; | 3672 labelElement = null; |
3656 } | 3673 } |
3657 } | 3674 } |
3658 return labelElement; | 3675 return labelElement; |
3659 } | 3676 } |
3660 | 3677 |
3661 /** | 3678 /** |
3662 * Look up the method with the given name in the given type. Return the elemen
t representing the | 3679 * Look up the method with the given name in the given type. Return the elemen
t representing the |
3663 * method that was found, or `null` if there is no method with the given name. | 3680 * method that was found, or `null` if there is no method with the given name. |
3664 * | 3681 * |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3851 * | 3868 * |
3852 * @param annotation the [Annotation] to resolve | 3869 * @param annotation the [Annotation] to resolve |
3853 * @param element the current known [Element] of the annotation, or [ClassElem
ent] | 3870 * @param element the current known [Element] of the annotation, or [ClassElem
ent] |
3854 * @param nameNode the name of the invoked constructor, may be `null` if unnam
ed constructor | 3871 * @param nameNode the name of the invoked constructor, may be `null` if unnam
ed constructor |
3855 * or not a constructor invocation | 3872 * or not a constructor invocation |
3856 */ | 3873 */ |
3857 void resolveAnnotationElement(Annotation annotation, Element element2, SimpleI
dentifier nameNode) { | 3874 void resolveAnnotationElement(Annotation annotation, Element element2, SimpleI
dentifier nameNode) { |
3858 if (element2 is PropertyAccessorElement) { | 3875 if (element2 is PropertyAccessorElement) { |
3859 PropertyAccessorElement accessorElement = element2 as PropertyAccessorElem
ent; | 3876 PropertyAccessorElement accessorElement = element2 as PropertyAccessorElem
ent; |
3860 if (!accessorElement.isSynthetic) { | 3877 if (!accessorElement.isSynthetic) { |
3861 _resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotatio
n, []); | 3878 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
3862 return; | 3879 return; |
3863 } | 3880 } |
3864 VariableElement variableElement = accessorElement.variable; | 3881 VariableElement variableElement = accessorElement.variable; |
3865 if (!variableElement.isConst) { | 3882 if (!variableElement.isConst) { |
3866 _resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotatio
n, []); | 3883 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
3867 } | 3884 } |
3868 return; | 3885 return; |
3869 } | 3886 } |
3870 if (element2 is ClassElement) { | 3887 if (element2 is ClassElement) { |
3871 if (nameNode == null) { | 3888 if (nameNode == null) { |
3872 nameNode = annotation.constructorName; | 3889 nameNode = annotation.constructorName; |
3873 } | 3890 } |
3874 String name = nameNode != null ? nameNode.name : null; | 3891 String name = nameNode != null ? nameNode.name : null; |
3875 ConstructorElement constructor; | 3892 ConstructorElement constructor; |
3876 { | 3893 { |
3877 InterfaceType interfaceType = new InterfaceTypeImpl.con1((element2 as Cl
assElement)); | 3894 InterfaceType interfaceType = new InterfaceTypeImpl.con1(element2 as Cla
ssElement); |
3878 LibraryElement definingLibrary = _resolver.definingLibrary; | 3895 LibraryElement definingLibrary = _resolver.definingLibrary; |
3879 constructor = interfaceType.lookUpConstructor(name, definingLibrary); | 3896 constructor = interfaceType.lookUpConstructor(name, definingLibrary); |
3880 } | 3897 } |
3881 if (constructor == null) { | 3898 if (constructor == null) { |
3882 _resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotatio
n, []); | 3899 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
3883 return; | 3900 return; |
3884 } | 3901 } |
3885 annotation.element = constructor; | 3902 annotation.element = constructor; |
3886 if (nameNode != null) { | 3903 if (nameNode != null) { |
3887 nameNode.staticElement = constructor; | 3904 nameNode.staticElement = constructor; |
3888 } | 3905 } |
3889 resolveAnnotationConstructorInvocationArguments(annotation, constructor); | 3906 resolveAnnotationConstructorInvocationArguments(annotation, constructor); |
3890 return; | 3907 return; |
3891 } | 3908 } |
3892 if (element2 != null) { | 3909 if (element2 != null) { |
3893 _resolver.reportError(CompileTimeErrorCode.INVALID_ANNOTATION, annotation,
[]); | 3910 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
, []); |
3894 } | 3911 } |
3895 } | 3912 } |
3896 | 3913 |
3897 /** | 3914 /** |
3898 * Given a list of arguments and the element that will be invoked using those
argument, compute | 3915 * Given a list of arguments and the element that will be invoked using those
argument, compute |
3899 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 3916 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
3900 * correspond to the arguments, or `null` if no correspondence could be comput
ed. | 3917 * correspond to the arguments, or `null` if no correspondence could be comput
ed. |
3901 * | 3918 * |
3902 * @param reportError if `true` then compile-time error should be reported; if
`false` | 3919 * @param reportError if `true` then compile-time error should be reported; if
`false` |
3903 * then compile-time warning | 3920 * then compile-time warning |
(...skipping 13 matching lines...) Expand all Loading... |
3917 * Given a list of arguments and the parameters related to the element that wi
ll be invoked using | 3934 * Given a list of arguments and the parameters related to the element that wi
ll be invoked using |
3918 * those argument, compute the list of parameters that correspond to the list
of arguments. Return | 3935 * those argument, compute the list of parameters that correspond to the list
of arguments. Return |
3919 * the parameters that correspond to the arguments. | 3936 * the parameters that correspond to the arguments. |
3920 * | 3937 * |
3921 * @param reportError if `true` then compile-time error should be reported; if
`false` | 3938 * @param reportError if `true` then compile-time error should be reported; if
`false` |
3922 * then compile-time warning | 3939 * then compile-time warning |
3923 * @param argumentList the list of arguments being passed to the element | 3940 * @param argumentList the list of arguments being passed to the element |
3924 * @param parameters the of the function that will be invoked with the argumen
ts | 3941 * @param parameters the of the function that will be invoked with the argumen
ts |
3925 * @return the parameters that correspond to the arguments | 3942 * @return the parameters that correspond to the arguments |
3926 */ | 3943 */ |
3927 List<ParameterElement> resolveArgumentsToParameters2(bool reportError2, Argume
ntList argumentList, List<ParameterElement> parameters) { | 3944 List<ParameterElement> resolveArgumentsToParameters2(bool reportError, Argumen
tList argumentList, List<ParameterElement> parameters) { |
3928 List<ParameterElement> requiredParameters = new List<ParameterElement>(); | 3945 List<ParameterElement> requiredParameters = new List<ParameterElement>(); |
3929 List<ParameterElement> positionalParameters = new List<ParameterElement>(); | 3946 List<ParameterElement> positionalParameters = new List<ParameterElement>(); |
3930 Map<String, ParameterElement> namedParameters = new Map<String, ParameterEle
ment>(); | 3947 Map<String, ParameterElement> namedParameters = new Map<String, ParameterEle
ment>(); |
3931 for (ParameterElement parameter in parameters) { | 3948 for (ParameterElement parameter in parameters) { |
3932 ParameterKind kind = parameter.parameterKind; | 3949 ParameterKind kind = parameter.parameterKind; |
3933 if (identical(kind, ParameterKind.REQUIRED)) { | 3950 if (identical(kind, ParameterKind.REQUIRED)) { |
3934 requiredParameters.add(parameter); | 3951 requiredParameters.add(parameter); |
3935 } else if (identical(kind, ParameterKind.POSITIONAL)) { | 3952 } else if (identical(kind, ParameterKind.POSITIONAL)) { |
3936 positionalParameters.add(parameter); | 3953 positionalParameters.add(parameter); |
3937 } else { | 3954 } else { |
3938 namedParameters[parameter.name] = parameter; | 3955 namedParameters[parameter.name] = parameter; |
3939 } | 3956 } |
3940 } | 3957 } |
3941 List<ParameterElement> unnamedParameters = new List<ParameterElement>.from(r
equiredParameters); | 3958 List<ParameterElement> unnamedParameters = new List<ParameterElement>.from(r
equiredParameters); |
3942 unnamedParameters.addAll(positionalParameters); | 3959 unnamedParameters.addAll(positionalParameters); |
3943 int unnamedParameterCount = unnamedParameters.length; | 3960 int unnamedParameterCount = unnamedParameters.length; |
3944 int unnamedIndex = 0; | 3961 int unnamedIndex = 0; |
3945 NodeList<Expression> arguments = argumentList.arguments; | 3962 NodeList<Expression> arguments = argumentList.arguments; |
3946 int argumentCount = arguments.length; | 3963 int argumentCount = arguments.length; |
3947 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum
entCount); | 3964 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum
entCount); |
3948 int positionalArgumentCount = 0; | 3965 int positionalArgumentCount = 0; |
3949 Set<String> usedNames = new Set<String>(); | 3966 Set<String> usedNames = new Set<String>(); |
3950 for (int i = 0; i < argumentCount; i++) { | 3967 for (int i = 0; i < argumentCount; i++) { |
3951 Expression argument = arguments[i]; | 3968 Expression argument = arguments[i]; |
3952 if (argument is NamedExpression) { | 3969 if (argument is NamedExpression) { |
3953 SimpleIdentifier nameNode = ((argument as NamedExpression)).name.label; | 3970 SimpleIdentifier nameNode = ((argument as NamedExpression)).name.label; |
3954 String name = nameNode.name; | 3971 String name = nameNode.name; |
3955 ParameterElement element = namedParameters[name]; | 3972 ParameterElement element = namedParameters[name]; |
3956 if (element == null) { | 3973 if (element == null) { |
3957 ErrorCode errorCode = (reportError2 ? CompileTimeErrorCode.UNDEFINED_N
AMED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER) as ErrorCode; | 3974 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.UNDEFINED_NA
MED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER) as ErrorCode; |
3958 _resolver.reportError(errorCode, nameNode, [name]); | 3975 _resolver.reportError5(errorCode, nameNode, [name]); |
3959 } else { | 3976 } else { |
3960 resolvedParameters[i] = element; | 3977 resolvedParameters[i] = element; |
3961 nameNode.staticElement = element; | 3978 nameNode.staticElement = element; |
3962 } | 3979 } |
3963 if (!javaSetAdd(usedNames, name)) { | 3980 if (!javaSetAdd(usedNames, name)) { |
3964 _resolver.reportError(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, n
ameNode, [name]); | 3981 _resolver.reportError5(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT,
nameNode, [name]); |
3965 } | 3982 } |
3966 } else { | 3983 } else { |
3967 positionalArgumentCount++; | 3984 positionalArgumentCount++; |
3968 if (unnamedIndex < unnamedParameterCount) { | 3985 if (unnamedIndex < unnamedParameterCount) { |
3969 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; | 3986 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; |
3970 } | 3987 } |
3971 } | 3988 } |
3972 } | 3989 } |
3973 if (positionalArgumentCount < requiredParameters.length) { | 3990 if (positionalArgumentCount < requiredParameters.length) { |
3974 ErrorCode errorCode = (reportError2 ? CompileTimeErrorCode.NOT_ENOUGH_REQU
IRED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS) as ErrorCode; | 3991 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.NOT_ENOUGH_REQUI
RED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS) as ErrorCode; |
3975 _resolver.reportError(errorCode, argumentList, [requiredParameters.length,
positionalArgumentCount]); | 3992 _resolver.reportError5(errorCode, argumentList, [requiredParameters.length
, positionalArgumentCount]); |
3976 } else if (positionalArgumentCount > unnamedParameterCount) { | 3993 } else if (positionalArgumentCount > unnamedParameterCount) { |
3977 ErrorCode errorCode = (reportError2 ? CompileTimeErrorCode.EXTRA_POSITIONA
L_ARGUMENTS : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS) as ErrorCode; | 3994 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.EXTRA_POSITIONAL
_ARGUMENTS : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS) as ErrorCode; |
3978 _resolver.reportError(errorCode, argumentList, [unnamedParameterCount, pos
itionalArgumentCount]); | 3995 _resolver.reportError5(errorCode, argumentList, [unnamedParameterCount, po
sitionalArgumentCount]); |
3979 } | 3996 } |
3980 return resolvedParameters; | 3997 return resolvedParameters; |
3981 } | 3998 } |
3982 | 3999 |
3983 /** | 4000 /** |
3984 * Resolve the names in the given combinators in the scope of the given librar
y. | 4001 * Resolve the names in the given combinators in the scope of the given librar
y. |
3985 * | 4002 * |
3986 * @param library the library that defines the names | 4003 * @param library the library that defines the names |
3987 * @param combinators the combinators containing the names to be resolved | 4004 * @param combinators the combinators containing the names to be resolved |
3988 */ | 4005 */ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4097 } | 4114 } |
4098 propertyName.staticElement = staticElement; | 4115 propertyName.staticElement = staticElement; |
4099 Type2 propagatedType = getPropagatedType(target); | 4116 Type2 propagatedType = getPropagatedType(target); |
4100 ExecutableElement propagatedElement = resolveProperty(target, propagatedType
, propertyName); | 4117 ExecutableElement propagatedElement = resolveProperty(target, propagatedType
, propertyName); |
4101 propertyName.propagatedElement = propagatedElement; | 4118 propertyName.propagatedElement = propagatedElement; |
4102 if (shouldReportMissingMember(staticType, staticElement) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedEl
ement))) { | 4119 if (shouldReportMissingMember(staticType, staticElement) && (_strictMode ||
propagatedType == null || shouldReportMissingMember(propagatedType, propagatedEl
ement))) { |
4103 Element selectedElement = select(staticElement, propagatedElement); | 4120 Element selectedElement = select(staticElement, propagatedElement); |
4104 bool isStaticProperty = isStatic(selectedElement); | 4121 bool isStaticProperty = isStatic(selectedElement); |
4105 if (propertyName.inSetterContext()) { | 4122 if (propertyName.inSetterContext()) { |
4106 if (isStaticProperty) { | 4123 if (isStaticProperty) { |
4107 _resolver.reportError(StaticWarningCode.UNDEFINED_SETTER, propertyName
, [propertyName.name, staticType.displayName]); | 4124 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticWarningCode.UNDEFINED_SETTER, propertyName, [propertyName.name, staticTyp
e.displayName]); |
4108 } else { | 4125 } else { |
4109 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SETTER, property
Name, [propertyName.name, staticType.displayName]); | 4126 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_SETTER, propertyName, [propertyName.name, stati
cType.displayName]); |
4110 } | 4127 } |
4111 } else if (propertyName.inGetterContext()) { | 4128 } else if (propertyName.inGetterContext()) { |
4112 if (isStaticProperty) { | 4129 if (isStaticProperty) { |
4113 _resolver.reportError(StaticWarningCode.UNDEFINED_GETTER, propertyName
, [propertyName.name, staticType.displayName]); | 4130 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticWarningCode.UNDEFINED_GETTER, propertyName, [propertyName.name, staticTyp
e.displayName]); |
4114 } else { | 4131 } else { |
4115 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_GETTER, property
Name, [propertyName.name, staticType.displayName]); | 4132 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element,
StaticTypeWarningCode.UNDEFINED_GETTER, propertyName, [propertyName.name, stati
cType.displayName]); |
4116 } | 4133 } |
4117 } else { | 4134 } else { |
4118 _resolver.reportError(StaticWarningCode.UNDEFINED_IDENTIFIER, propertyNa
me, [propertyName.name]); | 4135 _resolver.reportErrorProxyConditionalAnalysisError(staticType.element, S
taticWarningCode.UNDEFINED_IDENTIFIER, propertyName, [propertyName.name]); |
4119 } | 4136 } |
4120 } | 4137 } |
4121 } | 4138 } |
4122 | 4139 |
4123 /** | 4140 /** |
4124 * Resolve the given simple identifier if possible. Return the element to whic
h it could be | 4141 * Resolve the given simple identifier if possible. Return the element to whic
h it could be |
4125 * resolved, or `null` if it could not be resolved. This does not record the r
esults of the | 4142 * resolved, or `null` if it could not be resolved. This does not record the r
esults of the |
4126 * resolution. | 4143 * resolution. |
4127 * | 4144 * |
4128 * @param node the identifier to be resolved | 4145 * @param node the identifier to be resolved |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4257 ElementResolver_SyntheticIdentifier(String name) { | 4274 ElementResolver_SyntheticIdentifier(String name) { |
4258 this._name = name; | 4275 this._name = name; |
4259 } | 4276 } |
4260 accept(ASTVisitor visitor) => null; | 4277 accept(ASTVisitor visitor) => null; |
4261 sc.Token get beginToken => null; | 4278 sc.Token get beginToken => null; |
4262 Element get bestElement => null; | 4279 Element get bestElement => null; |
4263 sc.Token get endToken => null; | 4280 sc.Token get endToken => null; |
4264 String get name => _name; | 4281 String get name => _name; |
4265 Element get propagatedElement => null; | 4282 Element get propagatedElement => null; |
4266 Element get staticElement => null; | 4283 Element get staticElement => null; |
4267 void visitChildren(ASTVisitor<Object> visitor) { | 4284 void visitChildren(ASTVisitor visitor) { |
4268 } | 4285 } |
4269 } | 4286 } |
4270 /** | 4287 /** |
4271 * Instances of the class `InheritanceManager` manage the knowledge of where cla
ss members | 4288 * Instances of the class `InheritanceManager` manage the knowledge of where cla
ss members |
4272 * (methods, getters & setters) are inherited from. | 4289 * (methods, getters & setters) are inherited from. |
4273 * | 4290 * |
4274 * @coverage dart.engine.resolver | 4291 * @coverage dart.engine.resolver |
4275 */ | 4292 */ |
4276 class InheritanceManager { | 4293 class InheritanceManager { |
4277 | 4294 |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5710 * | 5727 * |
5711 * @param library the library to be processed to find libraries that have not
yet been traversed | 5728 * @param library the library to be processed to find libraries that have not
yet been traversed |
5712 * @throws AnalysisException if some portion of the library graph could not be
traversed | 5729 * @throws AnalysisException if some portion of the library graph could not be
traversed |
5713 */ | 5730 */ |
5714 void computeLibraryDependencies2(Library library, CompilationUnit unit) { | 5731 void computeLibraryDependencies2(Library library, CompilationUnit unit) { |
5715 Source librarySource = library.librarySource; | 5732 Source librarySource = library.librarySource; |
5716 Set<Source> exportedSources = new Set<Source>(); | 5733 Set<Source> exportedSources = new Set<Source>(); |
5717 Set<Source> importedSources = new Set<Source>(); | 5734 Set<Source> importedSources = new Set<Source>(); |
5718 for (Directive directive in unit.directives) { | 5735 for (Directive directive in unit.directives) { |
5719 if (directive is ExportDirective) { | 5736 if (directive is ExportDirective) { |
5720 Source exportSource = resolveSource(librarySource, (directive as ExportD
irective)); | 5737 Source exportSource = resolveSource(librarySource, directive as ExportDi
rective); |
5721 if (exportSource != null) { | 5738 if (exportSource != null) { |
5722 javaSetAdd(exportedSources, exportSource); | 5739 javaSetAdd(exportedSources, exportSource); |
5723 } | 5740 } |
5724 } else if (directive is ImportDirective) { | 5741 } else if (directive is ImportDirective) { |
5725 Source importSource = resolveSource(librarySource, (directive as ImportD
irective)); | 5742 Source importSource = resolveSource(librarySource, directive as ImportDi
rective); |
5726 if (importSource != null) { | 5743 if (importSource != null) { |
5727 javaSetAdd(importedSources, importSource); | 5744 javaSetAdd(importedSources, importSource); |
5728 } | 5745 } |
5729 } | 5746 } |
5730 } | 5747 } |
5731 computeLibraryDependencies3(library, new List.from(importedSources), new Lis
t.from(exportedSources)); | 5748 computeLibraryDependencies3(library, new List.from(importedSources), new Lis
t.from(exportedSources)); |
5732 } | 5749 } |
5733 | 5750 |
5734 /** | 5751 /** |
5735 * Recursively traverse the libraries reachable from the given library, creati
ng instances of the | 5752 * Recursively traverse the libraries reachable from the given library, creati
ng instances of the |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5902 * Resolve the identifiers and perform type analysis in the given library. | 5919 * Resolve the identifiers and perform type analysis in the given library. |
5903 * | 5920 * |
5904 * @param library the library to be resolved | 5921 * @param library the library to be resolved |
5905 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in | 5922 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in |
5906 * the library cannot be analyzed | 5923 * the library cannot be analyzed |
5907 */ | 5924 */ |
5908 void resolveReferencesAndTypes2(Library library) { | 5925 void resolveReferencesAndTypes2(Library library) { |
5909 for (Source source in library.compilationUnitSources) { | 5926 for (Source source in library.compilationUnitSources) { |
5910 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typeP
rovider); | 5927 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typeP
rovider); |
5911 library.getAST(source).accept(visitor); | 5928 library.getAST(source).accept(visitor); |
| 5929 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyConditi
onalAnalysisErrors) { |
| 5930 if (conditionalCode.shouldIncludeErrorCode()) { |
| 5931 visitor.reportError(conditionalCode.analysisError); |
| 5932 } |
| 5933 } |
5912 } | 5934 } |
5913 } | 5935 } |
5914 | 5936 |
5915 /** | 5937 /** |
5916 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | 5938 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
5917 * given library, or `null` if the URI is not valid. | 5939 * given library, or `null` if the URI is not valid. |
5918 * | 5940 * |
5919 * @param librarySource the source representing the library containing the dir
ective | 5941 * @param librarySource the source representing the library containing the dir
ective |
5920 * @param directive the directive which URI should be resolved | 5942 * @param directive the directive which URI should be resolved |
5921 * @return the result of resolving the URI against the URI of the library | 5943 * @return the result of resolving the URI against the URI of the library |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5963 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib
raryElement, _typeProvider, library.inheritanceManager); | 5985 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib
raryElement, _typeProvider, library.inheritanceManager); |
5964 unit.accept(errorVerifier); | 5986 unit.accept(errorVerifier); |
5965 } | 5987 } |
5966 if (_enableHints) { | 5988 if (_enableHints) { |
5967 HintGenerator hintGenerator = new HintGenerator(library.compilationUnits,
_analysisContext, _errorListener); | 5989 HintGenerator hintGenerator = new HintGenerator(library.compilationUnits,
_analysisContext, _errorListener); |
5968 hintGenerator.generateForLibrary(); | 5990 hintGenerator.generateForLibrary(); |
5969 } | 5991 } |
5970 } | 5992 } |
5971 } | 5993 } |
5972 /** | 5994 /** |
| 5995 * This class is a wrapper for an [AnalysisError] which can also be queried afte
r resolution |
| 5996 * to find out if the error should actually be reported. In this case, these err
ors are conditional |
| 5997 * on the non-existence of an `@proxy` annotation. |
| 5998 * |
| 5999 * If we have other conditional error codes in the future, we should have this c
lass implement some |
| 6000 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode
can be visited |
| 6001 * instead of multiple lists of *ConditionalErrorCodes. |
| 6002 */ |
| 6003 class ProxyConditionalAnalysisError { |
| 6004 |
| 6005 /** |
| 6006 * The name of the proxy annotation, from the meta pub package. |
| 6007 */ |
| 6008 static String _PROXY_ANNOTATION_NAME = "proxy"; |
| 6009 |
| 6010 /** |
| 6011 * The name of the meta library name, from the meta pub package. |
| 6012 */ |
| 6013 static String _META_LIBRARY_NAME = "meta"; |
| 6014 |
| 6015 /** |
| 6016 * Return `true` if the given element represents a class that has the proxy an
notation. |
| 6017 * |
| 6018 * @param element the class being tested |
| 6019 * @return `true` if the given element represents a class that has the proxy a
nnotation |
| 6020 */ |
| 6021 static bool classHasProxyAnnotation(Element element2) { |
| 6022 if (element2 is ClassElement) { |
| 6023 ClassElement classElement = element2 as ClassElement; |
| 6024 List<ElementAnnotation> annotations = classElement.metadata; |
| 6025 for (ElementAnnotation annotation in annotations) { |
| 6026 Element elementAnnotation = annotation.element; |
| 6027 if (elementAnnotation != null) { |
| 6028 LibraryElement lib = elementAnnotation.library; |
| 6029 if (elementAnnotation.name == _PROXY_ANNOTATION_NAME && lib != null &&
lib.name == _META_LIBRARY_NAME) { |
| 6030 return true; |
| 6031 } |
| 6032 } |
| 6033 } |
| 6034 } |
| 6035 return false; |
| 6036 } |
| 6037 |
| 6038 /** |
| 6039 * The enclosing [ClassElement], this is what will determine if the error code
should, or |
| 6040 * should not, be generated on the source. |
| 6041 */ |
| 6042 Element _enclosingElement; |
| 6043 |
| 6044 /** |
| 6045 * The conditional analysis error. |
| 6046 */ |
| 6047 AnalysisError _analysisError; |
| 6048 |
| 6049 /** |
| 6050 * Instantiate a new ProxyConditionalErrorCode with some enclosing element and
the conditional |
| 6051 * analysis error. |
| 6052 * |
| 6053 * @param enclosingElement the enclosing element |
| 6054 * @param analysisError the conditional analysis error |
| 6055 */ |
| 6056 ProxyConditionalAnalysisError(Element enclosingElement, AnalysisError analysis
Error) { |
| 6057 this._enclosingElement = enclosingElement; |
| 6058 this._analysisError = analysisError; |
| 6059 } |
| 6060 |
| 6061 /** |
| 6062 * Return the analysis error. |
| 6063 * |
| 6064 * @return the analysis error |
| 6065 */ |
| 6066 AnalysisError get analysisError => _analysisError; |
| 6067 |
| 6068 /** |
| 6069 * Return `true` iff the enclosing class has the proxy annotation. |
| 6070 * |
| 6071 * @return `true` iff the enclosing class has the proxy annotation |
| 6072 */ |
| 6073 bool shouldIncludeErrorCode() => !classHasProxyAnnotation(_enclosingElement); |
| 6074 } |
| 6075 /** |
5973 * Instances of the class `ResolverVisitor` are used to resolve the nodes within
a single | 6076 * Instances of the class `ResolverVisitor` are used to resolve the nodes within
a single |
5974 * compilation unit. | 6077 * compilation unit. |
5975 * | 6078 * |
5976 * @coverage dart.engine.resolver | 6079 * @coverage dart.engine.resolver |
5977 */ | 6080 */ |
5978 class ResolverVisitor extends ScopedVisitor { | 6081 class ResolverVisitor extends ScopedVisitor { |
5979 | 6082 |
5980 /** | 6083 /** |
5981 * The manager for the inheritance mappings. | 6084 * The manager for the inheritance mappings. |
5982 */ | 6085 */ |
(...skipping 20 matching lines...) Expand all Loading... |
6003 * current node is not contained in a function. | 6106 * current node is not contained in a function. |
6004 */ | 6107 */ |
6005 ExecutableElement _enclosingFunction = null; | 6108 ExecutableElement _enclosingFunction = null; |
6006 | 6109 |
6007 /** | 6110 /** |
6008 * The object keeping track of which elements have had their types overridden. | 6111 * The object keeping track of which elements have had their types overridden. |
6009 */ | 6112 */ |
6010 TypeOverrideManager _overrideManager = new TypeOverrideManager(); | 6113 TypeOverrideManager _overrideManager = new TypeOverrideManager(); |
6011 | 6114 |
6012 /** | 6115 /** |
| 6116 * Proxy conditional error codes. |
| 6117 */ |
| 6118 List<ProxyConditionalAnalysisError> _proxyConditionalAnalysisErrors = new List
<ProxyConditionalAnalysisError>(); |
| 6119 |
| 6120 /** |
6013 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 6121 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
6014 * | 6122 * |
6015 * @param library the library containing the compilation unit being resolved | 6123 * @param library the library containing the compilation unit being resolved |
6016 * @param source the source representing the compilation unit being visited | 6124 * @param source the source representing the compilation unit being visited |
6017 * @param typeProvider the object used to access the types from the core libra
ry | 6125 * @param typeProvider the object used to access the types from the core libra
ry |
6018 */ | 6126 */ |
6019 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider
) : super.con1(library, source, typeProvider) { | 6127 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider
) : super.con1(library, source, typeProvider) { |
6020 this._inheritanceManager = library.inheritanceManager; | 6128 this._inheritanceManager = library.inheritanceManager; |
6021 this._elementResolver = new ElementResolver(this); | 6129 this._elementResolver = new ElementResolver(this); |
6022 this._typeAnalyzer = new StaticTypeAnalyzer(this); | 6130 this._typeAnalyzer = new StaticTypeAnalyzer(this); |
(...skipping 14 matching lines...) Expand all Loading... |
6037 this._elementResolver = new ElementResolver(this); | 6145 this._elementResolver = new ElementResolver(this); |
6038 this._typeAnalyzer = new StaticTypeAnalyzer(this); | 6146 this._typeAnalyzer = new StaticTypeAnalyzer(this); |
6039 } | 6147 } |
6040 | 6148 |
6041 /** | 6149 /** |
6042 * Return the object keeping track of which elements have had their types over
ridden. | 6150 * Return the object keeping track of which elements have had their types over
ridden. |
6043 * | 6151 * |
6044 * @return the object keeping track of which elements have had their types ove
rridden | 6152 * @return the object keeping track of which elements have had their types ove
rridden |
6045 */ | 6153 */ |
6046 TypeOverrideManager get overrideManager => _overrideManager; | 6154 TypeOverrideManager get overrideManager => _overrideManager; |
| 6155 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro
xyConditionalAnalysisErrors; |
6047 Object visitAsExpression(AsExpression node) { | 6156 Object visitAsExpression(AsExpression node) { |
6048 super.visitAsExpression(node); | 6157 super.visitAsExpression(node); |
6049 override(node.expression, node.type.type); | 6158 override(node.expression, node.type.type); |
6050 return null; | 6159 return null; |
6051 } | 6160 } |
6052 Object visitAssertStatement(AssertStatement node) { | 6161 Object visitAssertStatement(AssertStatement node) { |
6053 super.visitAssertStatement(node); | 6162 super.visitAssertStatement(node); |
6054 propagateTrueState(node.condition); | 6163 propagateTrueState(node.condition); |
6055 return null; | 6164 return null; |
6056 } | 6165 } |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6514 PropertyInducingElement variable = element as PropertyInducingElement; | 6623 PropertyInducingElement variable = element as PropertyInducingElement; |
6515 if (!variable.isConst && !variable.isFinal) { | 6624 if (!variable.isConst && !variable.isFinal) { |
6516 return; | 6625 return; |
6517 } | 6626 } |
6518 } | 6627 } |
6519 Type2 currentType = getBestType(element); | 6628 Type2 currentType = getBestType(element); |
6520 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { | 6629 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { |
6521 _overrideManager.setType(element, potentialType); | 6630 _overrideManager.setType(element, potentialType); |
6522 } | 6631 } |
6523 } | 6632 } |
| 6633 |
| 6634 /** |
| 6635 * Report a conditional analysis error with the given error code and arguments
. |
| 6636 * |
| 6637 * @param enclosingElement the enclosing element |
| 6638 * @param errorCode the error code of the error to be reported |
| 6639 * @param node the node specifying the location of the error |
| 6640 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6641 */ |
| 6642 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC
ode errorCode, ASTNode node, List<Object> arguments) { |
| 6643 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos
ingElement, new AnalysisError.con2(source, node.offset, node.length, errorCode,
arguments))); |
| 6644 } |
| 6645 |
| 6646 /** |
| 6647 * Report a conditional analysis error with the given error code and arguments
. |
| 6648 * |
| 6649 * @param enclosingElement the enclosing element |
| 6650 * @param errorCode the error code of the error to be reported |
| 6651 * @param offset the offset of the location of the error |
| 6652 * @param length the length of the location of the error |
| 6653 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6654 */ |
| 6655 void reportErrorProxyConditionalAnalysisError2(Element enclosingElement, Error
Code errorCode, int offset, int length, List<Object> arguments) { |
| 6656 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos
ingElement, new AnalysisError.con2(source, offset, length, errorCode, arguments)
)); |
| 6657 } |
| 6658 |
| 6659 /** |
| 6660 * Report a conditional analysis error with the given error code and arguments
. |
| 6661 * |
| 6662 * @param enclosingElement the enclosing element |
| 6663 * @param errorCode the error code of the error to be reported |
| 6664 * @param token the token specifying the location of the error |
| 6665 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6666 */ |
| 6667 void reportErrorProxyConditionalAnalysisError3(Element enclosingElement, Error
Code errorCode, sc.Token token, List<Object> arguments) { |
| 6668 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos
ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode
, arguments))); |
| 6669 } |
6524 void visitForEachStatementInScope(ForEachStatement node) { | 6670 void visitForEachStatementInScope(ForEachStatement node) { |
6525 Expression iterator = node.iterator; | 6671 Expression iterator = node.iterator; |
6526 safelyVisit(iterator); | 6672 safelyVisit(iterator); |
6527 DeclaredIdentifier loopVariable = node.loopVariable; | 6673 DeclaredIdentifier loopVariable = node.loopVariable; |
6528 safelyVisit(loopVariable); | 6674 safelyVisit(loopVariable); |
6529 Statement body = node.body; | 6675 Statement body = node.body; |
6530 if (body != null) { | 6676 if (body != null) { |
6531 try { | 6677 try { |
6532 _overrideManager.enterScope(); | 6678 _overrideManager.enterScope(); |
6533 if (loopVariable != null && iterator != null) { | 6679 if (loopVariable != null && iterator != null) { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6853 * @return the library element for the library containing the compilation unit
being resolved | 6999 * @return the library element for the library containing the compilation unit
being resolved |
6854 */ | 7000 */ |
6855 LibraryElement get definingLibrary => _definingLibrary; | 7001 LibraryElement get definingLibrary => _definingLibrary; |
6856 | 7002 |
6857 /** | 7003 /** |
6858 * Return the object used to access the types from the core library. | 7004 * Return the object used to access the types from the core library. |
6859 * | 7005 * |
6860 * @return the object used to access the types from the core library | 7006 * @return the object used to access the types from the core library |
6861 */ | 7007 */ |
6862 TypeProvider get typeProvider => _typeProvider; | 7008 TypeProvider get typeProvider => _typeProvider; |
| 7009 |
| 7010 /** |
| 7011 * Report an error with the given analysis error. |
| 7012 * |
| 7013 * @param errorCode analysis error |
| 7014 */ |
| 7015 void reportError(AnalysisError analysisError) { |
| 7016 _errorListener.onError(analysisError); |
| 7017 } |
6863 Object visitBlock(Block node) { | 7018 Object visitBlock(Block node) { |
6864 Scope outerScope = _nameScope; | 7019 Scope outerScope = _nameScope; |
6865 try { | 7020 try { |
6866 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); | 7021 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); |
6867 hideNamesDefinedInBlock(enclosedScope, node); | 7022 hideNamesDefinedInBlock(enclosedScope, node); |
6868 _nameScope = enclosedScope; | 7023 _nameScope = enclosedScope; |
6869 super.visitBlock(node); | 7024 super.visitBlock(node); |
6870 } finally { | 7025 } finally { |
6871 _nameScope = outerScope; | 7026 _nameScope = outerScope; |
6872 } | 7027 } |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7102 LabelScope get labelScope => _labelScope; | 7257 LabelScope get labelScope => _labelScope; |
7103 | 7258 |
7104 /** | 7259 /** |
7105 * Return the name scope in which the current node is being resolved. | 7260 * Return the name scope in which the current node is being resolved. |
7106 * | 7261 * |
7107 * @return the name scope in which the current node is being resolved | 7262 * @return the name scope in which the current node is being resolved |
7108 */ | 7263 */ |
7109 Scope get nameScope => _nameScope; | 7264 Scope get nameScope => _nameScope; |
7110 | 7265 |
7111 /** | 7266 /** |
| 7267 * Return the source. |
| 7268 * |
| 7269 * @return the source |
| 7270 */ |
| 7271 Source get source => _source; |
| 7272 |
| 7273 /** |
7112 * Report an error with the given error code and arguments. | 7274 * Report an error with the given error code and arguments. |
7113 * | 7275 * |
7114 * @param errorCode the error code of the error to be reported | 7276 * @param errorCode the error code of the error to be reported |
7115 * @param node the node specifying the location of the error | 7277 * @param node the node specifying the location of the error |
7116 * @param arguments the arguments to the error, used to compose the error mess
age | 7278 * @param arguments the arguments to the error, used to compose the error mess
age |
7117 */ | 7279 */ |
7118 void reportError(ErrorCode errorCode, ASTNode node, List<Object> arguments) { | 7280 void reportError5(ErrorCode errorCode, ASTNode node, List<Object> arguments) { |
7119 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len
gth, errorCode, arguments)); | 7281 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len
gth, errorCode, arguments)); |
7120 } | 7282 } |
7121 | 7283 |
7122 /** | 7284 /** |
7123 * Report an error with the given error code and arguments. | 7285 * Report an error with the given error code and arguments. |
7124 * | 7286 * |
7125 * @param errorCode the error code of the error to be reported | 7287 * @param errorCode the error code of the error to be reported |
7126 * @param offset the offset of the location of the error | 7288 * @param offset the offset of the location of the error |
7127 * @param length the length of the location of the error | 7289 * @param length the length of the location of the error |
7128 * @param arguments the arguments to the error, used to compose the error mess
age | 7290 * @param arguments the arguments to the error, used to compose the error mess
age |
7129 */ | 7291 */ |
7130 void reportError5(ErrorCode errorCode, int offset, int length, List<Object> ar
guments) { | 7292 void reportError6(ErrorCode errorCode, int offset, int length, List<Object> ar
guments) { |
7131 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); | 7293 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); |
7132 } | 7294 } |
7133 | 7295 |
7134 /** | 7296 /** |
7135 * Report an error with the given error code and arguments. | 7297 * Report an error with the given error code and arguments. |
7136 * | 7298 * |
7137 * @param errorCode the error code of the error to be reported | 7299 * @param errorCode the error code of the error to be reported |
7138 * @param token the token specifying the location of the error | 7300 * @param token the token specifying the location of the error |
7139 * @param arguments the arguments to the error, used to compose the error mess
age | 7301 * @param arguments the arguments to the error, used to compose the error mess
age |
7140 */ | 7302 */ |
7141 void reportError6(ErrorCode errorCode, sc.Token token, List<Object> arguments)
{ | 7303 void reportError7(ErrorCode errorCode, sc.Token token, List<Object> arguments)
{ |
7142 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l
ength, errorCode, arguments)); | 7304 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l
ength, errorCode, arguments)); |
7143 } | 7305 } |
7144 | 7306 |
7145 /** | 7307 /** |
7146 * Visit the given AST node if it is not null. | 7308 * Visit the given AST node if it is not null. |
7147 * | 7309 * |
7148 * @param node the node to be visited | 7310 * @param node the node to be visited |
7149 */ | 7311 */ |
7150 void safelyVisit(ASTNode node) { | 7312 void safelyVisit(ASTNode node) { |
7151 if (node != null) { | 7313 if (node != null) { |
(...skipping 30 matching lines...) Expand all Loading... |
7182 } | 7344 } |
7183 | 7345 |
7184 /** | 7346 /** |
7185 * Visit the given statement after it's scope has been created. This is used b
y ResolverVisitor to | 7347 * Visit the given statement after it's scope has been created. This is used b
y ResolverVisitor to |
7186 * correctly visit the 'then' and 'else' statements of an 'if' statement. | 7348 * correctly visit the 'then' and 'else' statements of an 'if' statement. |
7187 * | 7349 * |
7188 * @param node the statement to be visited | 7350 * @param node the statement to be visited |
7189 */ | 7351 */ |
7190 void visitStatementInScope(Statement node) { | 7352 void visitStatementInScope(Statement node) { |
7191 if (node is Block) { | 7353 if (node is Block) { |
7192 visitBlock((node as Block)); | 7354 visitBlock(node as Block); |
7193 } else if (node != null) { | 7355 } else if (node != null) { |
7194 Scope outerNameScope = _nameScope; | 7356 Scope outerNameScope = _nameScope; |
7195 try { | 7357 try { |
7196 _nameScope = new EnclosedScope(_nameScope); | 7358 _nameScope = new EnclosedScope(_nameScope); |
7197 node.accept(this); | 7359 node.accept(this); |
7198 } finally { | 7360 } finally { |
7199 _nameScope = outerNameScope; | 7361 _nameScope = outerNameScope; |
7200 } | 7362 } |
7201 } | 7363 } |
7202 } | 7364 } |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8106 if (isNotTypeLiteral(node)) { | 8268 if (isNotTypeLiteral(node)) { |
8107 staticType = ((element as ClassElement)).type; | 8269 staticType = ((element as ClassElement)).type; |
8108 } else { | 8270 } else { |
8109 staticType = _typeProvider.typeType; | 8271 staticType = _typeProvider.typeType; |
8110 } | 8272 } |
8111 } else if (element is FunctionTypeAliasElement) { | 8273 } else if (element is FunctionTypeAliasElement) { |
8112 staticType = ((element as FunctionTypeAliasElement)).type; | 8274 staticType = ((element as FunctionTypeAliasElement)).type; |
8113 } else if (element is MethodElement) { | 8275 } else if (element is MethodElement) { |
8114 staticType = ((element as MethodElement)).type; | 8276 staticType = ((element as MethodElement)).type; |
8115 } else if (element is PropertyAccessorElement) { | 8277 } else if (element is PropertyAccessorElement) { |
8116 staticType = getType((element as PropertyAccessorElement), node.prefix.sta
ticType); | 8278 staticType = getType(element as PropertyAccessorElement, node.prefix.stati
cType); |
8117 } else if (element is ExecutableElement) { | 8279 } else if (element is ExecutableElement) { |
8118 staticType = ((element as ExecutableElement)).type; | 8280 staticType = ((element as ExecutableElement)).type; |
8119 } else if (element is TypeVariableElement) { | 8281 } else if (element is TypeVariableElement) { |
8120 staticType = ((element as TypeVariableElement)).type; | 8282 staticType = ((element as TypeVariableElement)).type; |
8121 } else if (element is VariableElement) { | 8283 } else if (element is VariableElement) { |
8122 staticType = ((element as VariableElement)).type; | 8284 staticType = ((element as VariableElement)).type; |
8123 } | 8285 } |
8124 recordStaticType(prefixedIdentifier, staticType); | 8286 recordStaticType(prefixedIdentifier, staticType); |
8125 recordStaticType(node, staticType); | 8287 recordStaticType(node, staticType); |
8126 Type2 propagatedType = _overrideManager.getType(element); | 8288 Type2 propagatedType = _overrideManager.getType(element); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8204 * | 8366 * |
8205 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> | 8367 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> |
8206 */ | 8368 */ |
8207 Object visitPropertyAccess(PropertyAccess node) { | 8369 Object visitPropertyAccess(PropertyAccess node) { |
8208 SimpleIdentifier propertyName = node.propertyName; | 8370 SimpleIdentifier propertyName = node.propertyName; |
8209 Element element = propertyName.staticElement; | 8371 Element element = propertyName.staticElement; |
8210 Type2 staticType = _dynamicType; | 8372 Type2 staticType = _dynamicType; |
8211 if (element is MethodElement) { | 8373 if (element is MethodElement) { |
8212 staticType = ((element as MethodElement)).type; | 8374 staticType = ((element as MethodElement)).type; |
8213 } else if (element is PropertyAccessorElement) { | 8375 } else if (element is PropertyAccessorElement) { |
8214 staticType = getType((element as PropertyAccessorElement), node.target !=
null ? getStaticType(node.target) : null); | 8376 staticType = getType(element as PropertyAccessorElement, node.target != nu
ll ? getStaticType(node.target) : null); |
8215 } else { | 8377 } else { |
8216 } | 8378 } |
8217 recordStaticType(propertyName, staticType); | 8379 recordStaticType(propertyName, staticType); |
8218 recordStaticType(node, staticType); | 8380 recordStaticType(node, staticType); |
8219 Type2 propagatedType = _overrideManager.getType(element); | 8381 Type2 propagatedType = _overrideManager.getType(element); |
8220 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ | 8382 if (propagatedType != null && propagatedType.isMoreSpecificThan(staticType))
{ |
8221 recordPropagatedType2(node, propagatedType); | 8383 recordPropagatedType2(node, propagatedType); |
8222 } | 8384 } |
8223 return null; | 8385 return null; |
8224 } | 8386 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8281 if (isNotTypeLiteral(node)) { | 8443 if (isNotTypeLiteral(node)) { |
8282 staticType = ((element as ClassElement)).type; | 8444 staticType = ((element as ClassElement)).type; |
8283 } else { | 8445 } else { |
8284 staticType = _typeProvider.typeType; | 8446 staticType = _typeProvider.typeType; |
8285 } | 8447 } |
8286 } else if (element is FunctionTypeAliasElement) { | 8448 } else if (element is FunctionTypeAliasElement) { |
8287 staticType = ((element as FunctionTypeAliasElement)).type; | 8449 staticType = ((element as FunctionTypeAliasElement)).type; |
8288 } else if (element is MethodElement) { | 8450 } else if (element is MethodElement) { |
8289 staticType = ((element as MethodElement)).type; | 8451 staticType = ((element as MethodElement)).type; |
8290 } else if (element is PropertyAccessorElement) { | 8452 } else if (element is PropertyAccessorElement) { |
8291 staticType = getType((element as PropertyAccessorElement), null); | 8453 staticType = getType(element as PropertyAccessorElement, null); |
8292 } else if (element is ExecutableElement) { | 8454 } else if (element is ExecutableElement) { |
8293 staticType = ((element as ExecutableElement)).type; | 8455 staticType = ((element as ExecutableElement)).type; |
8294 } else if (element is TypeVariableElement) { | 8456 } else if (element is TypeVariableElement) { |
8295 staticType = ((element as TypeVariableElement)).type; | 8457 staticType = ((element as TypeVariableElement)).type; |
8296 } else if (element is VariableElement) { | 8458 } else if (element is VariableElement) { |
8297 staticType = ((element as VariableElement)).type; | 8459 staticType = ((element as VariableElement)).type; |
8298 } else if (element is PrefixElement) { | 8460 } else if (element is PrefixElement) { |
8299 return null; | 8461 return null; |
8300 } else { | 8462 } else { |
8301 staticType = _dynamicType; | 8463 staticType = _dynamicType; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8630 if (getter != null) { | 8792 if (getter != null) { |
8631 functionType = getter.type; | 8793 functionType = getter.type; |
8632 if (functionType != null) { | 8794 if (functionType != null) { |
8633 return functionType.returnType; | 8795 return functionType.returnType; |
8634 } | 8796 } |
8635 } | 8797 } |
8636 return _dynamicType; | 8798 return _dynamicType; |
8637 } | 8799 } |
8638 Type2 returnType = functionType.returnType; | 8800 Type2 returnType = functionType.returnType; |
8639 if (returnType is TypeVariableType && context is InterfaceType) { | 8801 if (returnType is TypeVariableType && context is InterfaceType) { |
8640 InterfaceType interfaceTypeContext = (context as InterfaceType); | 8802 InterfaceType interfaceTypeContext = context as InterfaceType; |
8641 List<TypeVariableElement> parameterElements = interfaceTypeContext.element
!= null ? interfaceTypeContext.element.typeVariables : null; | 8803 List<TypeVariableElement> parameterElements = interfaceTypeContext.element
!= null ? interfaceTypeContext.element.typeVariables : null; |
8642 if (parameterElements != null) { | 8804 if (parameterElements != null) { |
8643 for (int i = 0; i < parameterElements.length; i++) { | 8805 for (int i = 0; i < parameterElements.length; i++) { |
8644 TypeVariableElement varElt = parameterElements[i]; | 8806 TypeVariableElement varElt = parameterElements[i]; |
8645 if (returnType.name == varElt.name) { | 8807 if (returnType.name == varElt.name) { |
8646 return interfaceTypeContext.typeArguments[i]; | 8808 return interfaceTypeContext.typeArguments[i]; |
8647 } | 8809 } |
8648 } | 8810 } |
8649 } | 8811 } |
8650 } | 8812 } |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9421 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 9583 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
9422 super.visitFunctionTypeAlias(node); | 9584 super.visitFunctionTypeAlias(node); |
9423 FunctionTypeAliasElementImpl element = node.element as FunctionTypeAliasElem
entImpl; | 9585 FunctionTypeAliasElementImpl element = node.element as FunctionTypeAliasElem
entImpl; |
9424 element.returnType = computeReturnType(node.returnType); | 9586 element.returnType = computeReturnType(node.returnType); |
9425 return null; | 9587 return null; |
9426 } | 9588 } |
9427 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 9589 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
9428 super.visitFunctionTypedFormalParameter(node); | 9590 super.visitFunctionTypedFormalParameter(node); |
9429 Element element = node.identifier.staticElement; | 9591 Element element = node.identifier.staticElement; |
9430 if (element is ParameterElementImpl) { | 9592 if (element is ParameterElementImpl) { |
9431 setFunctionTypedParameterType((element as ParameterElementImpl), node.retu
rnType, node.parameters); | 9593 setFunctionTypedParameterType(element as ParameterElementImpl, node.return
Type, node.parameters); |
9432 } else { | 9594 } else { |
9433 } | 9595 } |
9434 return null; | 9596 return null; |
9435 } | 9597 } |
9436 Object visitMethodDeclaration(MethodDeclaration node) { | 9598 Object visitMethodDeclaration(MethodDeclaration node) { |
9437 super.visitMethodDeclaration(node); | 9599 super.visitMethodDeclaration(node); |
9438 ExecutableElementImpl element = node.element as ExecutableElementImpl; | 9600 ExecutableElementImpl element = node.element as ExecutableElementImpl; |
9439 element.returnType = computeReturnType(node.returnType); | 9601 element.returnType = computeReturnType(node.returnType); |
9440 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); | 9602 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); |
9441 ClassElement definingClass = element.getAncestor(ClassElement); | 9603 ClassElement definingClass = element.getAncestor(ClassElement); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9501 } | 9663 } |
9502 ASTNode parent = node.parent; | 9664 ASTNode parent = node.parent; |
9503 if (typeName is PrefixedIdentifier && parent is ConstructorName && argumen
tList == null) { | 9665 if (typeName is PrefixedIdentifier && parent is ConstructorName && argumen
tList == null) { |
9504 ConstructorName name = parent as ConstructorName; | 9666 ConstructorName name = parent as ConstructorName; |
9505 if (name.name == null) { | 9667 if (name.name == null) { |
9506 PrefixedIdentifier prefixedIdentifier = typeName as PrefixedIdentifier
; | 9668 PrefixedIdentifier prefixedIdentifier = typeName as PrefixedIdentifier
; |
9507 SimpleIdentifier prefix = prefixedIdentifier.prefix; | 9669 SimpleIdentifier prefix = prefixedIdentifier.prefix; |
9508 element = nameScope.lookup(prefix, definingLibrary); | 9670 element = nameScope.lookup(prefix, definingLibrary); |
9509 if (element is PrefixElement) { | 9671 if (element is PrefixElement) { |
9510 if (parent.parent is InstanceCreationExpression && ((parent.parent a
s InstanceCreationExpression)).isConst) { | 9672 if (parent.parent is InstanceCreationExpression && ((parent.parent a
s InstanceCreationExpression)).isConst) { |
9511 reportError(CompileTimeErrorCode.CONST_WITH_NON_TYPE, prefixedIden
tifier.identifier, [prefixedIdentifier.identifier.name]); | 9673 reportError5(CompileTimeErrorCode.CONST_WITH_NON_TYPE, prefixedIde
ntifier.identifier, [prefixedIdentifier.identifier.name]); |
9512 } else { | 9674 } else { |
9513 reportError(StaticWarningCode.NEW_WITH_NON_TYPE, prefixedIdentifie
r.identifier, [prefixedIdentifier.identifier.name]); | 9675 reportError5(StaticWarningCode.NEW_WITH_NON_TYPE, prefixedIdentifi
er.identifier, [prefixedIdentifier.identifier.name]); |
9514 } | 9676 } |
9515 setElement(prefix, element); | 9677 setElement(prefix, element); |
9516 return null; | 9678 return null; |
9517 } else if (element != null) { | 9679 } else if (element != null) { |
9518 name.name = prefixedIdentifier.identifier; | 9680 name.name = prefixedIdentifier.identifier; |
9519 name.period = prefixedIdentifier.period; | 9681 name.period = prefixedIdentifier.period; |
9520 node.name = prefix; | 9682 node.name = prefix; |
9521 typeName = prefix; | 9683 typeName = prefix; |
9522 } | 9684 } |
9523 } | 9685 } |
9524 } | 9686 } |
9525 } | 9687 } |
9526 bool elementValid = element is! MultiplyDefinedElement; | 9688 bool elementValid = element is! MultiplyDefinedElement; |
9527 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation
Expression(node)) { | 9689 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation
Expression(node)) { |
9528 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); | 9690 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); |
9529 InstanceCreationExpression creation = node.parent.parent as InstanceCreati
onExpression; | 9691 InstanceCreationExpression creation = node.parent.parent as InstanceCreati
onExpression; |
9530 if (creation.isConst) { | 9692 if (creation.isConst) { |
9531 if (element == null) { | 9693 if (element == null) { |
9532 reportError(CompileTimeErrorCode.UNDEFINED_CLASS, typeNameSimple, [typ
eName]); | 9694 reportError5(CompileTimeErrorCode.UNDEFINED_CLASS, typeNameSimple, [ty
peName]); |
9533 } else { | 9695 } else { |
9534 reportError(CompileTimeErrorCode.CONST_WITH_NON_TYPE, typeNameSimple,
[typeName]); | 9696 reportError5(CompileTimeErrorCode.CONST_WITH_NON_TYPE, typeNameSimple,
[typeName]); |
9535 } | 9697 } |
9536 elementValid = false; | 9698 elementValid = false; |
9537 } else { | 9699 } else { |
9538 if (element != null) { | 9700 if (element != null) { |
9539 reportError(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [type
Name]); | 9701 reportError5(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [typ
eName]); |
9540 elementValid = false; | 9702 elementValid = false; |
9541 } | 9703 } |
9542 } | 9704 } |
9543 } | 9705 } |
9544 if (elementValid && element == null) { | 9706 if (elementValid && element == null) { |
9545 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); | 9707 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); |
9546 if (typeNameSimple.name == "boolean") { | 9708 if (typeNameSimple.name == "boolean") { |
9547 reportError(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSimple, [
]); | 9709 reportError5(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSimple,
[]); |
9548 } else if (isTypeNameInCatchClause(node)) { | 9710 } else if (isTypeNameInCatchClause(node)) { |
9549 reportError(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeN
ame.name]); | 9711 reportError5(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [type
Name.name]); |
9550 } else if (isTypeNameInAsExpression(node)) { | 9712 } else if (isTypeNameInAsExpression(node)) { |
9551 reportError(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name
]); | 9713 reportError5(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.nam
e]); |
9552 } else if (isTypeNameInIsExpression(node)) { | 9714 } else if (isTypeNameInIsExpression(node)) { |
9553 reportError(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.na
me]); | 9715 reportError5(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.n
ame]); |
9554 } else if (isTypeNameTargetInRedirectedConstructor(node)) { | 9716 } else if (isTypeNameTargetInRedirectedConstructor(node)) { |
9555 reportError(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeName
.name]); | 9717 reportError5(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeNam
e.name]); |
9556 } else if (isTypeNameInTypeArgumentList(node)) { | 9718 } else if (isTypeNameInTypeArgumentList(node)) { |
9557 reportError(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName, [
typeName.name]); | 9719 reportError5(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName,
[typeName.name]); |
9558 } else { | 9720 } else { |
9559 reportError(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeName.name]
); | 9721 reportError5(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeName.name
]); |
9560 } | 9722 } |
9561 elementValid = false; | 9723 elementValid = false; |
9562 } | 9724 } |
9563 if (!elementValid) { | 9725 if (!elementValid) { |
9564 if (element is MultiplyDefinedElement) { | 9726 if (element is MultiplyDefinedElement) { |
9565 setElement(typeName, element); | 9727 setElement(typeName, element); |
9566 } else { | 9728 } else { |
9567 setElement(typeName, _dynamicType.element); | 9729 setElement(typeName, _dynamicType.element); |
9568 } | 9730 } |
9569 typeName.staticType = _dynamicType; | 9731 typeName.staticType = _dynamicType; |
(...skipping 13 matching lines...) Expand all Loading... |
9583 if (argumentList != null) { | 9745 if (argumentList != null) { |
9584 } | 9746 } |
9585 } else if (element is MultiplyDefinedElement) { | 9747 } else if (element is MultiplyDefinedElement) { |
9586 List<Element> elements = ((element as MultiplyDefinedElement)).conflicting
Elements; | 9748 List<Element> elements = ((element as MultiplyDefinedElement)).conflicting
Elements; |
9587 type = getType(elements); | 9749 type = getType(elements); |
9588 if (type != null) { | 9750 if (type != null) { |
9589 node.type = type; | 9751 node.type = type; |
9590 } | 9752 } |
9591 } else { | 9753 } else { |
9592 if (isTypeNameInCatchClause(node)) { | 9754 if (isTypeNameInCatchClause(node)) { |
9593 reportError(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeN
ame.name]); | 9755 reportError5(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [type
Name.name]); |
9594 } else if (isTypeNameInAsExpression(node)) { | 9756 } else if (isTypeNameInAsExpression(node)) { |
9595 reportError(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name
]); | 9757 reportError5(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.nam
e]); |
9596 } else if (isTypeNameInIsExpression(node)) { | 9758 } else if (isTypeNameInIsExpression(node)) { |
9597 reportError(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.na
me]); | 9759 reportError5(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.n
ame]); |
9598 } else if (isTypeNameTargetInRedirectedConstructor(node)) { | 9760 } else if (isTypeNameTargetInRedirectedConstructor(node)) { |
9599 reportError(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeName
.name]); | 9761 reportError5(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeNam
e.name]); |
9600 } else if (isTypeNameInTypeArgumentList(node)) { | 9762 } else if (isTypeNameInTypeArgumentList(node)) { |
9601 reportError(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName, [
typeName.name]); | 9763 reportError5(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName,
[typeName.name]); |
9602 } else { | 9764 } else { |
9603 ASTNode parent = typeName.parent; | 9765 ASTNode parent = typeName.parent; |
9604 while (parent is TypeName) { | 9766 while (parent is TypeName) { |
9605 parent = parent.parent; | 9767 parent = parent.parent; |
9606 } | 9768 } |
9607 if (parent is ExtendsClause || parent is ImplementsClause || parent is W
ithClause || parent is ClassTypeAlias) { | 9769 if (parent is ExtendsClause || parent is ImplementsClause || parent is W
ithClause || parent is ClassTypeAlias) { |
9608 } else { | 9770 } else { |
9609 reportError(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); | 9771 reportError5(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); |
9610 } | 9772 } |
9611 } | 9773 } |
9612 setElement(typeName, _dynamicType.element); | 9774 setElement(typeName, _dynamicType.element); |
9613 typeName.staticType = _dynamicType; | 9775 typeName.staticType = _dynamicType; |
9614 node.type = _dynamicType; | 9776 node.type = _dynamicType; |
9615 return null; | 9777 return null; |
9616 } | 9778 } |
9617 if (argumentList != null) { | 9779 if (argumentList != null) { |
9618 NodeList<TypeName> arguments = argumentList.arguments; | 9780 NodeList<TypeName> arguments = argumentList.arguments; |
9619 int argumentCount = arguments.length; | 9781 int argumentCount = arguments.length; |
9620 List<Type2> parameters = getTypeArguments(type); | 9782 List<Type2> parameters = getTypeArguments(type); |
9621 int parameterCount = parameters.length; | 9783 int parameterCount = parameters.length; |
9622 int count = Math.min(argumentCount, parameterCount); | 9784 int count = Math.min(argumentCount, parameterCount); |
9623 List<Type2> typeArguments = new List<Type2>(); | 9785 List<Type2> typeArguments = new List<Type2>(); |
9624 for (int i = 0; i < count; i++) { | 9786 for (int i = 0; i < count; i++) { |
9625 Type2 argumentType = getType3(arguments[i]); | 9787 Type2 argumentType = getType3(arguments[i]); |
9626 if (argumentType != null) { | 9788 if (argumentType != null) { |
9627 typeArguments.add(argumentType); | 9789 typeArguments.add(argumentType); |
9628 } | 9790 } |
9629 } | 9791 } |
9630 if (argumentCount != parameterCount) { | 9792 if (argumentCount != parameterCount) { |
9631 reportError(getInvalidTypeParametersErrorCode(node), node, [typeName.nam
e, parameterCount, argumentCount]); | 9793 reportError5(getInvalidTypeParametersErrorCode(node), node, [typeName.na
me, parameterCount, argumentCount]); |
9632 } | 9794 } |
9633 argumentCount = typeArguments.length; | 9795 argumentCount = typeArguments.length; |
9634 if (argumentCount < parameterCount) { | 9796 if (argumentCount < parameterCount) { |
9635 for (int i = argumentCount; i < parameterCount; i++) { | 9797 for (int i = argumentCount; i < parameterCount; i++) { |
9636 typeArguments.add(_dynamicType); | 9798 typeArguments.add(_dynamicType); |
9637 } | 9799 } |
9638 } | 9800 } |
9639 if (type is InterfaceTypeImpl) { | 9801 if (type is InterfaceTypeImpl) { |
9640 InterfaceTypeImpl interfaceType = type as InterfaceTypeImpl; | 9802 InterfaceTypeImpl interfaceType = type as InterfaceTypeImpl; |
9641 type = interfaceType.substitute4(new List.from(typeArguments)); | 9803 type = interfaceType.substitute4(new List.from(typeArguments)); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9972 TypeName typeName = typeNames[i]; | 10134 TypeName typeName = typeNames[i]; |
9973 if (!detectedRepeatOnIndex[i]) { | 10135 if (!detectedRepeatOnIndex[i]) { |
9974 Element element = typeName.name.staticElement; | 10136 Element element = typeName.name.staticElement; |
9975 for (int j = i + 1; j < typeNames.length; j++) { | 10137 for (int j = i + 1; j < typeNames.length; j++) { |
9976 TypeName typeName2 = typeNames[j]; | 10138 TypeName typeName2 = typeNames[j]; |
9977 Identifier identifier2 = typeName2.name; | 10139 Identifier identifier2 = typeName2.name; |
9978 String name2 = identifier2.name; | 10140 String name2 = identifier2.name; |
9979 Element element2 = identifier2.staticElement; | 10141 Element element2 = identifier2.staticElement; |
9980 if (element != null && element == element2) { | 10142 if (element != null && element == element2) { |
9981 detectedRepeatOnIndex[j] = true; | 10143 detectedRepeatOnIndex[j] = true; |
9982 reportError(CompileTimeErrorCode.IMPLEMENTS_REPEATED, typeName2, [
name2]); | 10144 reportError5(CompileTimeErrorCode.IMPLEMENTS_REPEATED, typeName2,
[name2]); |
9983 } | 10145 } |
9984 } | 10146 } |
9985 } | 10147 } |
9986 } | 10148 } |
9987 } | 10149 } |
9988 } | 10150 } |
9989 | 10151 |
9990 /** | 10152 /** |
9991 * Return the type specified by the given name. | 10153 * Return the type specified by the given name. |
9992 * | 10154 * |
9993 * @param typeName the type name specifying the type to be returned | 10155 * @param typeName the type name specifying the type to be returned |
9994 * @param nonTypeError the error to produce if the type name is defined to be
something other than | 10156 * @param nonTypeError the error to produce if the type name is defined to be
something other than |
9995 * a type | 10157 * a type |
9996 * @param dynamicTypeError the error to produce if the type name is "dynamic" | 10158 * @param dynamicTypeError the error to produce if the type name is "dynamic" |
9997 * @return the type specified by the type name | 10159 * @return the type specified by the type name |
9998 */ | 10160 */ |
9999 InterfaceType resolveType(TypeName typeName, ErrorCode nonTypeError, ErrorCode
dynamicTypeError) { | 10161 InterfaceType resolveType(TypeName typeName, ErrorCode nonTypeError, ErrorCode
dynamicTypeError) { |
10000 Type2 type = typeName.type; | 10162 Type2 type = typeName.type; |
10001 if (type is InterfaceType) { | 10163 if (type is InterfaceType) { |
10002 return type as InterfaceType; | 10164 return type as InterfaceType; |
10003 } | 10165 } |
10004 Identifier name = typeName.name; | 10166 Identifier name = typeName.name; |
10005 if (name.name == sc.Keyword.DYNAMIC.syntax) { | 10167 if (name.name == sc.Keyword.DYNAMIC.syntax) { |
10006 reportError(dynamicTypeError, name, [name.name]); | 10168 reportError5(dynamicTypeError, name, [name.name]); |
10007 } else { | 10169 } else { |
10008 reportError(nonTypeError, name, [name.name]); | 10170 reportError5(nonTypeError, name, [name.name]); |
10009 } | 10171 } |
10010 return null; | 10172 return null; |
10011 } | 10173 } |
10012 | 10174 |
10013 /** | 10175 /** |
10014 * Resolve the types in the given list of type names. | 10176 * Resolve the types in the given list of type names. |
10015 * | 10177 * |
10016 * @param typeNames the type names to be resolved | 10178 * @param typeNames the type names to be resolved |
10017 * @param nonTypeError the error to produce if the type name is defined to be
something other than | 10179 * @param nonTypeError the error to produce if the type name is defined to be
something other than |
10018 * a type | 10180 * a type |
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12219 } | 12381 } |
12220 bool foundError = false; | 12382 bool foundError = false; |
12221 List<ASTNode> formalParameters = new List<ASTNode>(); | 12383 List<ASTNode> formalParameters = new List<ASTNode>(); |
12222 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>(); | 12384 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>(); |
12223 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme
ntImpl>(); | 12385 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme
ntImpl>(); |
12224 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters; | 12386 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters; |
12225 for (int i = 0; i < parameters2.length; i++) { | 12387 for (int i = 0; i < parameters2.length; i++) { |
12226 ParameterElement parameter = parameters2[i]; | 12388 ParameterElement parameter = parameters2[i]; |
12227 if (parameter.parameterKind.isOptional) { | 12389 if (parameter.parameterKind.isOptional) { |
12228 formalParameters.add(parameterLocations[i]); | 12390 formalParameters.add(parameterLocations[i]); |
12229 parameterElts.add((parameter as ParameterElementImpl)); | 12391 parameterElts.add(parameter as ParameterElementImpl); |
12230 } | 12392 } |
12231 } | 12393 } |
12232 for (ParameterElement parameterElt in overriddenPEs) { | 12394 for (ParameterElement parameterElt in overriddenPEs) { |
12233 if (parameterElt.parameterKind.isOptional) { | 12395 if (parameterElt.parameterKind.isOptional) { |
12234 if (parameterElt is ParameterElementImpl) { | 12396 if (parameterElt is ParameterElementImpl) { |
12235 overriddenParameterElts.add((parameterElt as ParameterElementImpl)); | 12397 overriddenParameterElts.add(parameterElt as ParameterElementImpl); |
12236 } else if (parameterElt is ParameterMember) { | 12398 } else if (parameterElt is ParameterMember) { |
12237 overriddenParameterElts.add((((parameterElt as ParameterMember)).baseE
lement as ParameterElementImpl)); | 12399 overriddenParameterElts.add(((parameterElt as ParameterMember)).baseEl
ement as ParameterElementImpl); |
12238 } | 12400 } |
12239 } | 12401 } |
12240 } | 12402 } |
12241 if (parameterElts.length > 0) { | 12403 if (parameterElts.length > 0) { |
12242 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) { | 12404 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) { |
12243 for (int i = 0; i < parameterElts.length; i++) { | 12405 for (int i = 0; i < parameterElts.length; i++) { |
12244 ParameterElementImpl parameterElt = parameterElts[i]; | 12406 ParameterElementImpl parameterElt = parameterElts[i]; |
12245 EvaluationResultImpl result = parameterElt.evaluationResult; | 12407 EvaluationResultImpl result = parameterElt.evaluationResult; |
12246 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) { | 12408 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) { |
12247 continue; | 12409 continue; |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12753 * @return `true` if and only if an error code is generated on the passed node | 12915 * @return `true` if and only if an error code is generated on the passed node |
12754 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED | 12916 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED |
12755 */ | 12917 */ |
12756 bool checkForCaseBlocksNotTerminated(SwitchStatement node) { | 12918 bool checkForCaseBlocksNotTerminated(SwitchStatement node) { |
12757 bool foundError = false; | 12919 bool foundError = false; |
12758 NodeList<SwitchMember> members = node.members; | 12920 NodeList<SwitchMember> members = node.members; |
12759 int lastMember = members.length - 1; | 12921 int lastMember = members.length - 1; |
12760 for (int i = 0; i < lastMember; i++) { | 12922 for (int i = 0; i < lastMember; i++) { |
12761 SwitchMember member = members[i]; | 12923 SwitchMember member = members[i]; |
12762 if (member is SwitchCase) { | 12924 if (member is SwitchCase) { |
12763 foundError = javaBooleanOr(foundError, checkForCaseBlockNotTerminated((m
ember as SwitchCase))); | 12925 foundError = javaBooleanOr(foundError, checkForCaseBlockNotTerminated(me
mber as SwitchCase)); |
12764 } | 12926 } |
12765 } | 12927 } |
12766 return foundError; | 12928 return foundError; |
12767 } | 12929 } |
12768 | 12930 |
12769 /** | 12931 /** |
12770 * This verifies that the passed switch statement does not have a case express
ion with the | 12932 * This verifies that the passed switch statement does not have a case express
ion with the |
12771 * operator '==' overridden. | 12933 * operator '==' overridden. |
12772 * | 12934 * |
12773 * @param node the switch statement to evaluate | 12935 * @param node the switch statement to evaluate |
(...skipping 2597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15371 } | 15533 } |
15372 } | 15534 } |
15373 return false; | 15535 return false; |
15374 } | 15536 } |
15375 } | 15537 } |
15376 /** | 15538 /** |
15377 * This enum holds one of four states of a field initialization state through a
constructor | 15539 * This enum holds one of four states of a field initialization state through a
constructor |
15378 * signature, not initialized, initialized in the field declaration, initialized
in the field | 15540 * signature, not initialized, initialized in the field declaration, initialized
in the field |
15379 * formal, and finally, initialized in the initializers list. | 15541 * formal, and finally, initialized in the initializers list. |
15380 */ | 15542 */ |
15381 class INIT_STATE implements Enum<INIT_STATE> { | 15543 class INIT_STATE extends Enum<INIT_STATE> { |
15382 static final INIT_STATE NOT_INIT = new INIT_STATE('NOT_INIT', 0); | 15544 static final INIT_STATE NOT_INIT = new INIT_STATE('NOT_INIT', 0); |
15383 static final INIT_STATE INIT_IN_DECLARATION = new INIT_STATE('INIT_IN_DECLARAT
ION', 1); | 15545 static final INIT_STATE INIT_IN_DECLARATION = new INIT_STATE('INIT_IN_DECLARAT
ION', 1); |
15384 static final INIT_STATE INIT_IN_FIELD_FORMAL = new INIT_STATE('INIT_IN_FIELD_F
ORMAL', 2); | 15546 static final INIT_STATE INIT_IN_FIELD_FORMAL = new INIT_STATE('INIT_IN_FIELD_F
ORMAL', 2); |
15385 static final INIT_STATE INIT_IN_INITIALIZERS = new INIT_STATE('INIT_IN_INITIAL
IZERS', 3); | 15547 static final INIT_STATE INIT_IN_INITIALIZERS = new INIT_STATE('INIT_IN_INITIAL
IZERS', 3); |
15386 static final List<INIT_STATE> values = [ | 15548 static final List<INIT_STATE> values = [ |
15387 NOT_INIT, | 15549 NOT_INIT, |
15388 INIT_IN_DECLARATION, | 15550 INIT_IN_DECLARATION, |
15389 INIT_IN_FIELD_FORMAL, | 15551 INIT_IN_FIELD_FORMAL, |
15390 INIT_IN_INITIALIZERS]; | 15552 INIT_IN_INITIALIZERS]; |
15391 | 15553 INIT_STATE(String name, int ordinal) : super(name, ordinal); |
15392 /// The name of this enum constant, as declared in the enum declaration. | |
15393 final String name; | |
15394 | |
15395 /// The position in the enum declaration. | |
15396 final int ordinal; | |
15397 INIT_STATE(this.name, this.ordinal); | |
15398 int compareTo(INIT_STATE other) => ordinal - other.ordinal; | |
15399 int get hashCode => ordinal; | |
15400 String toString() => name; | |
15401 } | 15554 } |
15402 class GeneralizingElementVisitor_11 extends GeneralizingElementVisitor<Object> { | 15555 class GeneralizingElementVisitor_11 extends GeneralizingElementVisitor<Object> { |
15403 Element target; | 15556 Element target; |
15404 List<Element> toCheck; | 15557 List<Element> toCheck; |
15405 GeneralizingElementVisitor_11(this.target, this.toCheck) : super(); | 15558 GeneralizingElementVisitor_11(this.target, this.toCheck) : super(); |
15406 bool _inClass = false; | 15559 bool _inClass = false; |
15407 Object visitClassElement(ClassElement element) { | 15560 Object visitClassElement(ClassElement element) { |
15408 addTypeToCheck(element.supertype); | 15561 addTypeToCheck(element.supertype); |
15409 for (InterfaceType mixin in element.mixins) { | 15562 for (InterfaceType mixin in element.mixins) { |
15410 addTypeToCheck(mixin); | 15563 addTypeToCheck(mixin); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15454 } | 15607 } |
15455 } | 15608 } |
15456 /** | 15609 /** |
15457 * The enumeration `ResolverErrorCode` defines the error codes used for errors d
etected by the | 15610 * The enumeration `ResolverErrorCode` defines the error codes used for errors d
etected by the |
15458 * resolver. The convention for this class is for the name of the error code to
indicate the problem | 15611 * resolver. The convention for this class is for the name of the error code to
indicate the problem |
15459 * that caused the error to be generated and for the error message to explain wh
at is wrong and, | 15612 * that caused the error to be generated and for the error message to explain wh
at is wrong and, |
15460 * when appropriate, how the problem can be corrected. | 15613 * when appropriate, how the problem can be corrected. |
15461 * | 15614 * |
15462 * @coverage dart.engine.resolver | 15615 * @coverage dart.engine.resolver |
15463 */ | 15616 */ |
15464 class ResolverErrorCode implements Enum<ResolverErrorCode>, ErrorCode { | 15617 class ResolverErrorCode extends Enum<ResolverErrorCode> implements ErrorCode { |
15465 static final ResolverErrorCode BREAK_LABEL_ON_SWITCH_MEMBER = new ResolverErro
rCode('BREAK_LABEL_ON_SWITCH_MEMBER', 0, ErrorType.COMPILE_TIME_ERROR, "Break la
bel resolves to case or default statement"); | 15618 static final ResolverErrorCode BREAK_LABEL_ON_SWITCH_MEMBER = new ResolverErro
rCode.con1('BREAK_LABEL_ON_SWITCH_MEMBER', 0, ErrorType.COMPILE_TIME_ERROR, "Bre
ak label resolves to case or default statement"); |
15466 static final ResolverErrorCode CONTINUE_LABEL_ON_SWITCH = new ResolverErrorCod
e('CONTINUE_LABEL_ON_SWITCH', 1, ErrorType.COMPILE_TIME_ERROR, "A continue label
resolves to switch, must be loop or switch member"); | 15619 static final ResolverErrorCode CONTINUE_LABEL_ON_SWITCH = new ResolverErrorCod
e.con1('CONTINUE_LABEL_ON_SWITCH', 1, ErrorType.COMPILE_TIME_ERROR, "A continue
label resolves to switch, must be loop or switch member"); |
15467 static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new Resol
verErrorCode('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TIME_ER
ROR, "Libraries that have parts must have a library directive"); | 15620 static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new Resol
verErrorCode.con1('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TI
ME_ERROR, "Libraries that have parts must have a library directive"); |
15468 static final List<ResolverErrorCode> values = [ | 15621 static final List<ResolverErrorCode> values = [ |
15469 BREAK_LABEL_ON_SWITCH_MEMBER, | 15622 BREAK_LABEL_ON_SWITCH_MEMBER, |
15470 CONTINUE_LABEL_ON_SWITCH, | 15623 CONTINUE_LABEL_ON_SWITCH, |
15471 MISSING_LIBRARY_DIRECTIVE_WITH_PART]; | 15624 MISSING_LIBRARY_DIRECTIVE_WITH_PART]; |
15472 | 15625 |
15473 /// The name of this enum constant, as declared in the enum declaration. | |
15474 final String name; | |
15475 | |
15476 /// The position in the enum declaration. | |
15477 final int ordinal; | |
15478 | |
15479 /** | 15626 /** |
15480 * The type of this error. | 15627 * The type of this error. |
15481 */ | 15628 */ |
15482 ErrorType _type; | 15629 ErrorType _type; |
15483 | 15630 |
15484 /** | 15631 /** |
15485 * The message template used to create the message to be displayed for this er
ror. | 15632 * The template used to create the message to be displayed for this error. |
15486 */ | 15633 */ |
15487 String _message; | 15634 String _message; |
15488 | 15635 |
15489 /** | 15636 /** |
| 15637 * The template used to create the correction to be displayed for this error,
or `null` if |
| 15638 * there is no correction information for this error. |
| 15639 */ |
| 15640 String correction9; |
| 15641 |
| 15642 /** |
15490 * Initialize a newly created error code to have the given type and message. | 15643 * Initialize a newly created error code to have the given type and message. |
15491 * | 15644 * |
15492 * @param type the type of this error | 15645 * @param type the type of this error |
15493 * @param message the message template used to create the message to be displa
yed for the error | 15646 * @param message the message template used to create the message to be displa
yed for the error |
15494 */ | 15647 */ |
15495 ResolverErrorCode(this.name, this.ordinal, ErrorType type, String message) { | 15648 ResolverErrorCode.con1(String name, int ordinal, ErrorType type, String messag
e) : super(name, ordinal) { |
15496 this._type = type; | 15649 this._type = type; |
15497 this._message = message; | 15650 this._message = message; |
15498 } | 15651 } |
| 15652 |
| 15653 /** |
| 15654 * Initialize a newly created error code to have the given type, message and c
orrection. |
| 15655 * |
| 15656 * @param type the type of this error |
| 15657 * @param message the template used to create the message to be displayed for
the error |
| 15658 * @param correction the template used to create the correction to be displaye
d for the error |
| 15659 */ |
| 15660 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { |
| 15661 this._type = type; |
| 15662 this._message = message; |
| 15663 this.correction9 = correction; |
| 15664 } |
| 15665 String get correction => correction9; |
15499 ErrorSeverity get errorSeverity => _type.severity; | 15666 ErrorSeverity get errorSeverity => _type.severity; |
15500 String get message => _message; | 15667 String get message => _message; |
15501 ErrorType get type => _type; | 15668 ErrorType get type => _type; |
15502 int compareTo(ResolverErrorCode other) => ordinal - other.ordinal; | |
15503 int get hashCode => ordinal; | |
15504 String toString() => name; | |
15505 } | 15669 } |
OLD | NEW |