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

Side by Side Diff: packages/analyzer/lib/src/generated/element_resolver.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver.element_resolver; 5 library engine.resolver.element_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart'; 9 import 'ast.dart';
10 import 'element.dart'; 10 import 'element.dart';
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 String methodName = operatorType.lexeme; 154 String methodName = operatorType.lexeme;
155 DartType staticType = _getStaticType(leftHandSide); 155 DartType staticType = _getStaticType(leftHandSide);
156 MethodElement staticMethod = 156 MethodElement staticMethod =
157 _lookUpMethod(leftHandSide, staticType, methodName); 157 _lookUpMethod(leftHandSide, staticType, methodName);
158 node.staticElement = staticMethod; 158 node.staticElement = staticMethod;
159 DartType propagatedType = _getPropagatedType(leftHandSide); 159 DartType propagatedType = _getPropagatedType(leftHandSide);
160 MethodElement propagatedMethod = 160 MethodElement propagatedMethod =
161 _lookUpMethod(leftHandSide, propagatedType, methodName); 161 _lookUpMethod(leftHandSide, propagatedType, methodName);
162 node.propagatedElement = propagatedMethod; 162 node.propagatedElement = propagatedMethod;
163 if (_shouldReportMissingMember(staticType, staticMethod)) { 163 if (_shouldReportMissingMember(staticType, staticMethod)) {
164 _recordUndefinedToken(staticType.element, 164 _recordUndefinedToken(
165 StaticTypeWarningCode.UNDEFINED_METHOD, operator, [ 165 staticType.element,
166 methodName, 166 StaticTypeWarningCode.UNDEFINED_METHOD,
167 staticType.displayName 167 operator,
168 ]); 168 [methodName, staticType.displayName]);
169 } else if (_enableHints && 169 } else if (_enableHints &&
170 _shouldReportMissingMember(propagatedType, propagatedMethod) && 170 _shouldReportMissingMember(propagatedType, propagatedMethod) &&
171 !_memberFoundInSubclass( 171 !_memberFoundInSubclass(
172 propagatedType.element, methodName, true, false)) { 172 propagatedType.element, methodName, true, false)) {
173 _recordUndefinedToken(propagatedType.element, 173 _recordUndefinedToken(
174 HintCode.UNDEFINED_METHOD, operator, [ 174 propagatedType.element,
175 methodName, 175 HintCode.UNDEFINED_METHOD,
176 propagatedType.displayName 176 operator,
177 ]); 177 [methodName, propagatedType.displayName]);
178 } 178 }
179 } 179 }
180 } 180 }
181 return null; 181 return null;
182 } 182 }
183 183
184 @override 184 @override
185 Object visitBinaryExpression(BinaryExpression node) { 185 Object visitBinaryExpression(BinaryExpression node) {
186 sc.Token operator = node.operator; 186 sc.Token operator = node.operator;
187 if (operator.isUserDefinableOperator) { 187 if (operator.isUserDefinableOperator) {
188 _resolveBinaryExpression(node, operator.lexeme); 188 _resolveBinaryExpression(node, operator.lexeme);
189 } else if (operator.type == sc.TokenType.BANG_EQ) { 189 } else if (operator.type == sc.TokenType.BANG_EQ) {
190 _resolveBinaryExpression(node, sc.TokenType.EQ_EQ.lexeme); 190 _resolveBinaryExpression(node, sc.TokenType.EQ_EQ.lexeme);
191 } 191 }
192 return null; 192 return null;
193 } 193 }
194 194
195 @override 195 @override
196 Object visitBreakStatement(BreakStatement node) { 196 Object visitBreakStatement(BreakStatement node) {
197 node.target = _lookupBreakOrContinueTarget(node, node.label, false); 197 node.target = _lookupBreakOrContinueTarget(node, node.label, false);
198 return null; 198 return null;
199 } 199 }
200 200
201 @override 201 @override
202 Object visitClassDeclaration(ClassDeclaration node) { 202 Object visitClassDeclaration(ClassDeclaration node) {
203 setMetadata(node.element, node); 203 setMetadata(node.element, node);
204 return null; 204 return null;
205 } 205 }
206
206 @override 207 @override
207 Object visitClassTypeAlias(ClassTypeAlias node) { 208 Object visitClassTypeAlias(ClassTypeAlias node) {
208 setMetadata(node.element, node); 209 setMetadata(node.element, node);
209 return null; 210 return null;
210 } 211 }
211 212
212 @override 213 @override
213 Object visitCommentReference(CommentReference node) { 214 Object visitCommentReference(CommentReference node) {
214 Identifier identifier = node.identifier; 215 Identifier identifier = node.identifier;
215 if (identifier is SimpleIdentifier) { 216 if (identifier is SimpleIdentifier) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 if (isInGetterContext && isInSetterContext) { 488 if (isInGetterContext && isInSetterContext) {
488 // lookup setter 489 // lookup setter
489 MethodElement setterStaticMethod = 490 MethodElement setterStaticMethod =
490 _lookUpMethod(target, staticType, setterMethodName); 491 _lookUpMethod(target, staticType, setterMethodName);
491 MethodElement setterPropagatedMethod = 492 MethodElement setterPropagatedMethod =
492 _lookUpMethod(target, propagatedType, setterMethodName); 493 _lookUpMethod(target, propagatedType, setterMethodName);
493 // set setter element 494 // set setter element
494 node.staticElement = setterStaticMethod; 495 node.staticElement = setterStaticMethod;
495 node.propagatedElement = setterPropagatedMethod; 496 node.propagatedElement = setterPropagatedMethod;
496 // generate undefined method warning 497 // generate undefined method warning
497 _checkForUndefinedIndexOperator(node, target, getterMethodName, 498 _checkForUndefinedIndexOperator(
498 setterStaticMethod, setterPropagatedMethod, staticType, 499 node,
500 target,
501 getterMethodName,
502 setterStaticMethod,
503 setterPropagatedMethod,
504 staticType,
499 propagatedType); 505 propagatedType);
500 // lookup getter method 506 // lookup getter method
501 MethodElement getterStaticMethod = 507 MethodElement getterStaticMethod =
502 _lookUpMethod(target, staticType, getterMethodName); 508 _lookUpMethod(target, staticType, getterMethodName);
503 MethodElement getterPropagatedMethod = 509 MethodElement getterPropagatedMethod =
504 _lookUpMethod(target, propagatedType, getterMethodName); 510 _lookUpMethod(target, propagatedType, getterMethodName);
505 // set getter element 511 // set getter element
506 AuxiliaryElements auxiliaryElements = 512 AuxiliaryElements auxiliaryElements =
507 new AuxiliaryElements(getterStaticMethod, getterPropagatedMethod); 513 new AuxiliaryElements(getterStaticMethod, getterPropagatedMethod);
508 node.auxiliaryElements = auxiliaryElements; 514 node.auxiliaryElements = auxiliaryElements;
509 // generate undefined method warning 515 // generate undefined method warning
510 _checkForUndefinedIndexOperator(node, target, getterMethodName, 516 _checkForUndefinedIndexOperator(
511 getterStaticMethod, getterPropagatedMethod, staticType, 517 node,
518 target,
519 getterMethodName,
520 getterStaticMethod,
521 getterPropagatedMethod,
522 staticType,
512 propagatedType); 523 propagatedType);
513 } else if (isInGetterContext) { 524 } else if (isInGetterContext) {
514 // lookup getter method 525 // lookup getter method
515 MethodElement staticMethod = 526 MethodElement staticMethod =
516 _lookUpMethod(target, staticType, getterMethodName); 527 _lookUpMethod(target, staticType, getterMethodName);
517 MethodElement propagatedMethod = 528 MethodElement propagatedMethod =
518 _lookUpMethod(target, propagatedType, getterMethodName); 529 _lookUpMethod(target, propagatedType, getterMethodName);
519 // set getter element 530 // set getter element
520 node.staticElement = staticMethod; 531 node.staticElement = staticMethod;
521 node.propagatedElement = propagatedMethod; 532 node.propagatedElement = propagatedMethod;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 Element propagatedElement; 596 Element propagatedElement;
586 DartType staticType = null; 597 DartType staticType = null;
587 DartType propagatedType = null; 598 DartType propagatedType = null;
588 if (target == null) { 599 if (target == null) {
589 staticElement = _resolveInvokedElement(methodName); 600 staticElement = _resolveInvokedElement(methodName);
590 propagatedElement = null; 601 propagatedElement = null;
591 } else if (methodName.name == FunctionElement.LOAD_LIBRARY_NAME && 602 } else if (methodName.name == FunctionElement.LOAD_LIBRARY_NAME &&
592 _isDeferredPrefix(target)) { 603 _isDeferredPrefix(target)) {
593 if (node.operator.type == sc.TokenType.QUESTION_PERIOD) { 604 if (node.operator.type == sc.TokenType.QUESTION_PERIOD) {
594 _resolver.reportErrorForNode( 605 _resolver.reportErrorForNode(
595 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, target, 606 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
607 target,
596 [(target as SimpleIdentifier).name]); 608 [(target as SimpleIdentifier).name]);
597 } 609 }
598 LibraryElement importedLibrary = _getImportedLibrary(target); 610 LibraryElement importedLibrary = _getImportedLibrary(target);
599 methodName.staticElement = importedLibrary.loadLibraryFunction; 611 methodName.staticElement = importedLibrary.loadLibraryFunction;
600 return null; 612 return null;
601 } else { 613 } else {
602 staticType = _getStaticType(target); 614 staticType = _getStaticType(target);
603 propagatedType = _getPropagatedType(target); 615 propagatedType = _getPropagatedType(target);
604 // 616 //
605 // If this method invocation is of the form 'C.m' where 'C' is a class, 617 // If this method invocation is of the form 'C.m' where 'C' is a class,
606 // then we don't call resolveInvokedElement(...) which walks up the class 618 // then we don't call resolveInvokedElement(...) which walks up the class
607 // hierarchy, instead we just look for the member in the type only. This 619 // hierarchy, instead we just look for the member in the type only. This
608 // does not apply to conditional method invocation (i.e. 'C?.m(...)'). 620 // does not apply to conditional method invocation (i.e. 'C?.m(...)').
609 // 621 //
610 bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD; 622 bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD;
611 ClassElementImpl typeReference = getTypeReference(target, isConditional); 623 ClassElementImpl typeReference = getTypeReference(target);
612 if (typeReference != null) { 624 if (typeReference != null) {
613 staticElement = 625 staticElement =
614 propagatedElement = _resolveElement(typeReference, methodName); 626 propagatedElement = _resolveElement(typeReference, methodName);
615 } else { 627 } else {
616 staticElement = _resolveInvokedElementWithTarget( 628 staticElement = _resolveInvokedElementWithTarget(
617 target, staticType, methodName, isConditional); 629 target, staticType, methodName, isConditional);
618 propagatedElement = _resolveInvokedElementWithTarget( 630 propagatedElement = _resolveInvokedElementWithTarget(
619 target, propagatedType, methodName, isConditional); 631 target, propagatedType, methodName, isConditional);
620 } 632 }
621 } 633 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 methodName.name == FunctionElement.CALL_METHOD_NAME) { 726 methodName.name == FunctionElement.CALL_METHOD_NAME) {
715 // TODO(brianwilkerson) Can we ever resolve the function being 727 // TODO(brianwilkerson) Can we ever resolve the function being
716 // invoked? 728 // invoked?
717 // resolveArgumentsToParameters(node.getArgumentList(), invokedFunction ); 729 // resolveArgumentsToParameters(node.getArgumentList(), invokedFunction );
718 return null; 730 return null;
719 } 731 }
720 targetTypeName = targetType == null ? null : targetType.displayName; 732 targetTypeName = targetType == null ? null : targetType.displayName;
721 ErrorCode proxyErrorCode = (generatedWithTypePropagation 733 ErrorCode proxyErrorCode = (generatedWithTypePropagation
722 ? HintCode.UNDEFINED_METHOD 734 ? HintCode.UNDEFINED_METHOD
723 : StaticTypeWarningCode.UNDEFINED_METHOD); 735 : StaticTypeWarningCode.UNDEFINED_METHOD);
724 _recordUndefinedNode(targetType.element, proxyErrorCode, methodName, [ 736 _recordUndefinedNode(targetType.element, proxyErrorCode, methodName,
725 methodName.name, 737 [methodName.name, targetTypeName]);
726 targetTypeName
727 ]);
728 } 738 }
729 } else if (identical( 739 } else if (identical(
730 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) { 740 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) {
731 // Generate the type name. 741 // Generate the type name.
732 // The error code will never be generated via type propagation 742 // The error code will never be generated via type propagation
733 DartType targetType = _getStaticType(target); 743 DartType targetType = _getStaticType(target);
734 if (targetType is InterfaceType && !targetType.isObject) { 744 if (targetType is InterfaceType && !targetType.isObject) {
735 targetType = (targetType as InterfaceType).superclass; 745 targetType = (targetType as InterfaceType).superclass;
736 } 746 }
737 String targetTypeName = targetType == null ? null : targetType.name; 747 String targetTypeName = targetType == null ? null : targetType.name;
(...skipping 21 matching lines...) Expand all
759 String methodName = _getPostfixOperator(node); 769 String methodName = _getPostfixOperator(node);
760 DartType staticType = _getStaticType(operand); 770 DartType staticType = _getStaticType(operand);
761 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName); 771 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName);
762 node.staticElement = staticMethod; 772 node.staticElement = staticMethod;
763 DartType propagatedType = _getPropagatedType(operand); 773 DartType propagatedType = _getPropagatedType(operand);
764 MethodElement propagatedMethod = 774 MethodElement propagatedMethod =
765 _lookUpMethod(operand, propagatedType, methodName); 775 _lookUpMethod(operand, propagatedType, methodName);
766 node.propagatedElement = propagatedMethod; 776 node.propagatedElement = propagatedMethod;
767 if (_shouldReportMissingMember(staticType, staticMethod)) { 777 if (_shouldReportMissingMember(staticType, staticMethod)) {
768 if (operand is SuperExpression) { 778 if (operand is SuperExpression) {
769 _recordUndefinedToken(staticType.element, 779 _recordUndefinedToken(
770 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, node.operator, [ 780 staticType.element,
771 methodName, 781 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR,
772 staticType.displayName 782 node.operator,
773 ]); 783 [methodName, staticType.displayName]);
774 } else { 784 } else {
775 _recordUndefinedToken(staticType.element, 785 _recordUndefinedToken(
776 StaticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [ 786 staticType.element,
777 methodName, 787 StaticTypeWarningCode.UNDEFINED_OPERATOR,
778 staticType.displayName 788 node.operator,
779 ]); 789 [methodName, staticType.displayName]);
780 } 790 }
781 } else if (_enableHints && 791 } else if (_enableHints &&
782 _shouldReportMissingMember(propagatedType, propagatedMethod) && 792 _shouldReportMissingMember(propagatedType, propagatedMethod) &&
783 !_memberFoundInSubclass( 793 !_memberFoundInSubclass(
784 propagatedType.element, methodName, true, false)) { 794 propagatedType.element, methodName, true, false)) {
785 _recordUndefinedToken(propagatedType.element, HintCode.UNDEFINED_OPERATOR, 795 _recordUndefinedToken(propagatedType.element, HintCode.UNDEFINED_OPERATOR,
786 node.operator, [methodName, propagatedType.displayName]); 796 node.operator, [methodName, propagatedType.displayName]);
787 } 797 }
788 return null; 798 return null;
789 } 799 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 859 }
850 // May be annotation, resolve invocation of "const" constructor. 860 // May be annotation, resolve invocation of "const" constructor.
851 if (node.parent is Annotation) { 861 if (node.parent is Annotation) {
852 Annotation annotation = node.parent as Annotation; 862 Annotation annotation = node.parent as Annotation;
853 _resolveAnnotationElement(annotation); 863 _resolveAnnotationElement(annotation);
854 } 864 }
855 // 865 //
856 // Otherwise, the prefix is really an expression that happens to be a simple 866 // Otherwise, the prefix is really an expression that happens to be a simple
857 // identifier and this is really equivalent to a property access node. 867 // identifier and this is really equivalent to a property access node.
858 // 868 //
859 _resolvePropertyAccess(prefix, identifier, false); 869 _resolvePropertyAccess(prefix, identifier);
860 return null; 870 return null;
861 } 871 }
862 872
863 @override 873 @override
864 Object visitPrefixExpression(PrefixExpression node) { 874 Object visitPrefixExpression(PrefixExpression node) {
865 sc.Token operator = node.operator; 875 sc.Token operator = node.operator;
866 sc.TokenType operatorType = operator.type; 876 sc.TokenType operatorType = operator.type;
867 if (operatorType.isUserDefinableOperator || 877 if (operatorType.isUserDefinableOperator ||
868 operatorType == sc.TokenType.PLUS_PLUS || 878 operatorType == sc.TokenType.PLUS_PLUS ||
869 operatorType == sc.TokenType.MINUS_MINUS) { 879 operatorType == sc.TokenType.MINUS_MINUS) {
870 Expression operand = node.operand; 880 Expression operand = node.operand;
871 String methodName = _getPrefixOperator(node); 881 String methodName = _getPrefixOperator(node);
872 DartType staticType = _getStaticType(operand); 882 DartType staticType = _getStaticType(operand);
873 MethodElement staticMethod = 883 MethodElement staticMethod =
874 _lookUpMethod(operand, staticType, methodName); 884 _lookUpMethod(operand, staticType, methodName);
875 node.staticElement = staticMethod; 885 node.staticElement = staticMethod;
876 DartType propagatedType = _getPropagatedType(operand); 886 DartType propagatedType = _getPropagatedType(operand);
877 MethodElement propagatedMethod = 887 MethodElement propagatedMethod =
878 _lookUpMethod(operand, propagatedType, methodName); 888 _lookUpMethod(operand, propagatedType, methodName);
879 node.propagatedElement = propagatedMethod; 889 node.propagatedElement = propagatedMethod;
880 if (_shouldReportMissingMember(staticType, staticMethod)) { 890 if (_shouldReportMissingMember(staticType, staticMethod)) {
881 if (operand is SuperExpression) { 891 if (operand is SuperExpression) {
882 _recordUndefinedToken(staticType.element, 892 _recordUndefinedToken(
883 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, operator, [ 893 staticType.element,
884 methodName, 894 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR,
885 staticType.displayName 895 operator,
886 ]); 896 [methodName, staticType.displayName]);
887 } else { 897 } else {
888 _recordUndefinedToken(staticType.element, 898 _recordUndefinedToken(
889 StaticTypeWarningCode.UNDEFINED_OPERATOR, operator, [ 899 staticType.element,
890 methodName, 900 StaticTypeWarningCode.UNDEFINED_OPERATOR,
891 staticType.displayName 901 operator,
892 ]); 902 [methodName, staticType.displayName]);
893 } 903 }
894 } else if (_enableHints && 904 } else if (_enableHints &&
895 _shouldReportMissingMember(propagatedType, propagatedMethod) && 905 _shouldReportMissingMember(propagatedType, propagatedMethod) &&
896 !_memberFoundInSubclass( 906 !_memberFoundInSubclass(
897 propagatedType.element, methodName, true, false)) { 907 propagatedType.element, methodName, true, false)) {
898 _recordUndefinedToken(propagatedType.element, 908 _recordUndefinedToken(
899 HintCode.UNDEFINED_OPERATOR, operator, [ 909 propagatedType.element,
900 methodName, 910 HintCode.UNDEFINED_OPERATOR,
901 propagatedType.displayName 911 operator,
902 ]); 912 [methodName, propagatedType.displayName]);
903 } 913 }
904 } 914 }
905 return null; 915 return null;
906 } 916 }
907 917
908 @override 918 @override
909 Object visitPropertyAccess(PropertyAccess node) { 919 Object visitPropertyAccess(PropertyAccess node) {
910 Expression target = node.realTarget; 920 Expression target = node.realTarget;
911 if (target is SuperExpression && !_isSuperInValidContext(target)) { 921 if (target is SuperExpression && !_isSuperInValidContext(target)) {
912 return null; 922 return null;
913 } 923 }
914 SimpleIdentifier propertyName = node.propertyName; 924 SimpleIdentifier propertyName = node.propertyName;
915 _resolvePropertyAccess(target, propertyName, 925 _resolvePropertyAccess(target, propertyName);
916 node.operator.type == sc.TokenType.QUESTION_PERIOD);
917 return null; 926 return null;
918 } 927 }
919 928
920 @override 929 @override
921 Object visitRedirectingConstructorInvocation( 930 Object visitRedirectingConstructorInvocation(
922 RedirectingConstructorInvocation node) { 931 RedirectingConstructorInvocation node) {
923 ClassElement enclosingClass = _resolver.enclosingClass; 932 ClassElement enclosingClass = _resolver.enclosingClass;
924 if (enclosingClass == null) { 933 if (enclosingClass == null) {
925 // TODO(brianwilkerson) Report this error. 934 // TODO(brianwilkerson) Report this error.
926 return null; 935 return null;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 // TODO(brianwilkerson) Recover from this error. 1008 // TODO(brianwilkerson) Recover from this error.
1000 if (_isConstructorReturnType(node)) { 1009 if (_isConstructorReturnType(node)) {
1001 _resolver.reportErrorForNode( 1010 _resolver.reportErrorForNode(
1002 CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node); 1011 CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, node);
1003 } else if (node.parent is Annotation) { 1012 } else if (node.parent is Annotation) {
1004 Annotation annotation = node.parent as Annotation; 1013 Annotation annotation = node.parent as Annotation;
1005 _resolver.reportErrorForNode( 1014 _resolver.reportErrorForNode(
1006 CompileTimeErrorCode.INVALID_ANNOTATION, annotation); 1015 CompileTimeErrorCode.INVALID_ANNOTATION, annotation);
1007 } else if (element is PrefixElement) { 1016 } else if (element is PrefixElement) {
1008 _resolver.reportErrorForNode( 1017 _resolver.reportErrorForNode(
1009 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, node, 1018 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
1019 node,
1010 [element.name]); 1020 [element.name]);
1011 } else { 1021 } else {
1012 _recordUndefinedNode(_resolver.enclosingClass, 1022 _recordUndefinedNode(_resolver.enclosingClass,
1013 StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]); 1023 StaticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]);
1014 } 1024 }
1015 } 1025 }
1016 node.staticElement = element; 1026 node.staticElement = element;
1017 if (node.inSetterContext() && 1027 if (node.inSetterContext() &&
1018 node.inGetterContext() && 1028 node.inGetterContext() &&
1019 enclosingClass != null) { 1029 enclosingClass != null) {
(...skipping 26 matching lines...) Expand all
1046 } 1056 }
1047 SimpleIdentifier name = node.constructorName; 1057 SimpleIdentifier name = node.constructorName;
1048 String superName = name != null ? name.name : null; 1058 String superName = name != null ? name.name : null;
1049 ConstructorElement element = 1059 ConstructorElement element =
1050 superType.lookUpConstructor(superName, _definingLibrary); 1060 superType.lookUpConstructor(superName, _definingLibrary);
1051 if (element == null || 1061 if (element == null ||
1052 (!enclosingClass.doesMixinLackConstructors && 1062 (!enclosingClass.doesMixinLackConstructors &&
1053 !enclosingClass.isSuperConstructorAccessible(element))) { 1063 !enclosingClass.isSuperConstructorAccessible(element))) {
1054 if (name != null) { 1064 if (name != null) {
1055 _resolver.reportErrorForNode( 1065 _resolver.reportErrorForNode(
1056 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER, node, [ 1066 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER,
1057 superType.displayName, 1067 node,
1058 name 1068 [superType.displayName, name]);
1059 ]);
1060 } else { 1069 } else {
1061 _resolver.reportErrorForNode( 1070 _resolver.reportErrorForNode(
1062 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT, 1071 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT,
1063 node, [superType.displayName]); 1072 node,
1073 [superType.displayName]);
1064 } 1074 }
1065 return null; 1075 return null;
1066 } else { 1076 } else {
1067 if (element.isFactory) { 1077 if (element.isFactory) {
1068 _resolver.reportErrorForNode( 1078 _resolver.reportErrorForNode(
1069 CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node, [element]); 1079 CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node, [element]);
1070 } 1080 }
1071 } 1081 }
1072 if (name != null) { 1082 if (name != null) {
1073 name.staticElement = element; 1083 name.staticElement = element;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 } 1201 }
1192 return null; 1202 return null;
1193 } 1203 }
1194 1204
1195 /** 1205 /**
1196 * Check that the given index [expression] was resolved, otherwise a 1206 * Check that the given index [expression] was resolved, otherwise a
1197 * [StaticTypeWarningCode.UNDEFINED_OPERATOR] is generated. The [target] is 1207 * [StaticTypeWarningCode.UNDEFINED_OPERATOR] is generated. The [target] is
1198 * the target of the expression. The [methodName] is the name of the operator 1208 * the target of the expression. The [methodName] is the name of the operator
1199 * associated with the context of using of the given index expression. 1209 * associated with the context of using of the given index expression.
1200 */ 1210 */
1201 bool _checkForUndefinedIndexOperator(IndexExpression expression, 1211 bool _checkForUndefinedIndexOperator(
1202 Expression target, String methodName, MethodElement staticMethod, 1212 IndexExpression expression,
1203 MethodElement propagatedMethod, DartType staticType, 1213 Expression target,
1214 String methodName,
1215 MethodElement staticMethod,
1216 MethodElement propagatedMethod,
1217 DartType staticType,
1204 DartType propagatedType) { 1218 DartType propagatedType) {
1205 bool shouldReportMissingMember_static = 1219 bool shouldReportMissingMember_static =
1206 _shouldReportMissingMember(staticType, staticMethod); 1220 _shouldReportMissingMember(staticType, staticMethod);
1207 bool shouldReportMissingMember_propagated = 1221 bool shouldReportMissingMember_propagated =
1208 !shouldReportMissingMember_static && 1222 !shouldReportMissingMember_static &&
1209 _enableHints && 1223 _enableHints &&
1210 _shouldReportMissingMember(propagatedType, propagatedMethod) && 1224 _shouldReportMissingMember(propagatedType, propagatedMethod) &&
1211 !_memberFoundInSubclass( 1225 !_memberFoundInSubclass(
1212 propagatedType.element, methodName, true, false); 1226 propagatedType.element, methodName, true, false);
1213 if (shouldReportMissingMember_static || 1227 if (shouldReportMissingMember_static ||
1214 shouldReportMissingMember_propagated) { 1228 shouldReportMissingMember_propagated) {
1215 sc.Token leftBracket = expression.leftBracket; 1229 sc.Token leftBracket = expression.leftBracket;
1216 sc.Token rightBracket = expression.rightBracket; 1230 sc.Token rightBracket = expression.rightBracket;
1217 ErrorCode errorCode; 1231 ErrorCode errorCode;
1218 if (shouldReportMissingMember_static) { 1232 if (shouldReportMissingMember_static) {
1219 if (target is SuperExpression) { 1233 if (target is SuperExpression) {
1220 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR; 1234 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR;
1221 } else { 1235 } else {
1222 errorCode = StaticTypeWarningCode.UNDEFINED_OPERATOR; 1236 errorCode = StaticTypeWarningCode.UNDEFINED_OPERATOR;
1223 } 1237 }
1224 } else { 1238 } else {
1225 errorCode = HintCode.UNDEFINED_OPERATOR; 1239 errorCode = HintCode.UNDEFINED_OPERATOR;
1226 } 1240 }
1227 DartType type = 1241 DartType type =
1228 shouldReportMissingMember_static ? staticType : propagatedType; 1242 shouldReportMissingMember_static ? staticType : propagatedType;
1229 if (leftBracket == null || rightBracket == null) { 1243 if (leftBracket == null || rightBracket == null) {
1230 _recordUndefinedNode(type.element, errorCode, expression, [ 1244 _recordUndefinedNode(type.element, errorCode, expression,
1231 methodName, 1245 [methodName, type.displayName]);
1232 type.displayName
1233 ]);
1234 } else { 1246 } else {
1235 int offset = leftBracket.offset; 1247 int offset = leftBracket.offset;
1236 int length = rightBracket.offset - offset + 1; 1248 int length = rightBracket.offset - offset + 1;
1237 _recordUndefinedOffset(type.element, errorCode, offset, length, [ 1249 _recordUndefinedOffset(type.element, errorCode, offset, length,
1238 methodName, 1250 [methodName, type.displayName]);
1239 type.displayName
1240 ]);
1241 } 1251 }
1242 return true; 1252 return true;
1243 } 1253 }
1244 return false; 1254 return false;
1245 } 1255 }
1246 1256
1247 /** 1257 /**
1248 * Given an [argumentList] and the executable [element] that will be invoked 1258 * Given an [argumentList] and the executable [element] that will be invoked
1249 * using those arguments, compute the list of parameters that correspond to 1259 * using those arguments, compute the list of parameters that correspond to
1250 * the list of arguments. Return the parameters that correspond to the 1260 * the list of arguments. Return the parameters that correspond to the
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 /** 1585 /**
1576 * Look up the getter with the given [getterName] in the interfaces 1586 * Look up the getter with the given [getterName] in the interfaces
1577 * implemented by the given [targetType], either directly or indirectly. 1587 * implemented by the given [targetType], either directly or indirectly.
1578 * Return the element representing the getter that was found, or `null` if 1588 * Return the element representing the getter that was found, or `null` if
1579 * there is no getter with the given name. The flag [includeTargetType] should 1589 * there is no getter with the given name. The flag [includeTargetType] should
1580 * be `true` if the search should include the target type. The 1590 * be `true` if the search should include the target type. The
1581 * [visitedInterfaces] is a set containing all of the interfaces that have 1591 * [visitedInterfaces] is a set containing all of the interfaces that have
1582 * been examined, used to prevent infinite recursion and to optimize the 1592 * been examined, used to prevent infinite recursion and to optimize the
1583 * search. 1593 * search.
1584 */ 1594 */
1585 PropertyAccessorElement _lookUpGetterInInterfaces(InterfaceType targetType, 1595 PropertyAccessorElement _lookUpGetterInInterfaces(
1586 bool includeTargetType, String getterName, 1596 InterfaceType targetType,
1597 bool includeTargetType,
1598 String getterName,
1587 HashSet<ClassElement> visitedInterfaces) { 1599 HashSet<ClassElement> visitedInterfaces) {
1588 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the 1600 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the
1589 // specification (titled "Inheritance and Overriding" under "Interfaces") 1601 // specification (titled "Inheritance and Overriding" under "Interfaces")
1590 // describes a much more complex scheme for finding the inherited member. 1602 // describes a much more complex scheme for finding the inherited member.
1591 // We need to follow that scheme. The code below should cover the 80% case. 1603 // We need to follow that scheme. The code below should cover the 80% case.
1592 ClassElement targetClass = targetType.element; 1604 ClassElement targetClass = targetType.element;
1593 if (visitedInterfaces.contains(targetClass)) { 1605 if (visitedInterfaces.contains(targetClass)) {
1594 return null; 1606 return null;
1595 } 1607 }
1596 visitedInterfaces.add(targetClass); 1608 visitedInterfaces.add(targetClass);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 /** 1661 /**
1650 * Look up the method or getter with the given [memberName] in the interfaces 1662 * Look up the method or getter with the given [memberName] in the interfaces
1651 * implemented by the given [targetType], either directly or indirectly. 1663 * implemented by the given [targetType], either directly or indirectly.
1652 * Return the element representing the method or getter that was found, or 1664 * Return the element representing the method or getter that was found, or
1653 * `null` if there is no method or getter with the given name. The flag 1665 * `null` if there is no method or getter with the given name. The flag
1654 * [includeTargetType] should be `true` if the search should include the 1666 * [includeTargetType] should be `true` if the search should include the
1655 * target type. The [visitedInterfaces] is a set containing all of the 1667 * target type. The [visitedInterfaces] is a set containing all of the
1656 * interfaces that have been examined, used to prevent infinite recursion and 1668 * interfaces that have been examined, used to prevent infinite recursion and
1657 * to optimize the search. 1669 * to optimize the search.
1658 */ 1670 */
1659 ExecutableElement _lookUpGetterOrMethodInInterfaces(InterfaceType targetType, 1671 ExecutableElement _lookUpGetterOrMethodInInterfaces(
1660 bool includeTargetType, String memberName, 1672 InterfaceType targetType,
1673 bool includeTargetType,
1674 String memberName,
1661 HashSet<ClassElement> visitedInterfaces) { 1675 HashSet<ClassElement> visitedInterfaces) {
1662 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the 1676 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the
1663 // specification (titled "Inheritance and Overriding" under "Interfaces") 1677 // specification (titled "Inheritance and Overriding" under "Interfaces")
1664 // describes a much more complex scheme for finding the inherited member. 1678 // describes a much more complex scheme for finding the inherited member.
1665 // We need to follow that scheme. The code below should cover the 80% case. 1679 // We need to follow that scheme. The code below should cover the 80% case.
1666 ClassElement targetClass = targetType.element; 1680 ClassElement targetClass = targetType.element;
1667 if (visitedInterfaces.contains(targetClass)) { 1681 if (visitedInterfaces.contains(targetClass)) {
1668 return null; 1682 return null;
1669 } 1683 }
1670 visitedInterfaces.add(targetClass); 1684 visitedInterfaces.add(targetClass);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 /** 1744 /**
1731 * Look up the method with the given [methodName] in the interfaces 1745 * Look up the method with the given [methodName] in the interfaces
1732 * implemented by the given [targetType], either directly or indirectly. 1746 * implemented by the given [targetType], either directly or indirectly.
1733 * Return the element representing the method that was found, or `null` if 1747 * Return the element representing the method that was found, or `null` if
1734 * there is no method with the given name. The flag [includeTargetType] should 1748 * there is no method with the given name. The flag [includeTargetType] should
1735 * be `true` if the search should include the target type. The 1749 * be `true` if the search should include the target type. The
1736 * [visitedInterfaces] is a set containing all of the interfaces that have 1750 * [visitedInterfaces] is a set containing all of the interfaces that have
1737 * been examined, used to prevent infinite recursion and to optimize the 1751 * been examined, used to prevent infinite recursion and to optimize the
1738 * search. 1752 * search.
1739 */ 1753 */
1740 MethodElement _lookUpMethodInInterfaces(InterfaceType targetType, 1754 MethodElement _lookUpMethodInInterfaces(
1741 bool includeTargetType, String methodName, 1755 InterfaceType targetType,
1756 bool includeTargetType,
1757 String methodName,
1742 HashSet<ClassElement> visitedInterfaces) { 1758 HashSet<ClassElement> visitedInterfaces) {
1743 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the 1759 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the
1744 // specification (titled "Inheritance and Overriding" under "Interfaces") 1760 // specification (titled "Inheritance and Overriding" under "Interfaces")
1745 // describes a much more complex scheme for finding the inherited member. 1761 // describes a much more complex scheme for finding the inherited member.
1746 // We need to follow that scheme. The code below should cover the 80% case. 1762 // We need to follow that scheme. The code below should cover the 80% case.
1747 ClassElement targetClass = targetType.element; 1763 ClassElement targetClass = targetType.element;
1748 if (visitedInterfaces.contains(targetClass)) { 1764 if (visitedInterfaces.contains(targetClass)) {
1749 return null; 1765 return null;
1750 } 1766 }
1751 visitedInterfaces.add(targetClass); 1767 visitedInterfaces.add(targetClass);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 * Look up the setter with the given [setterName] in the interfaces 1824 * Look up the setter with the given [setterName] in the interfaces
1809 * implemented by the given [targetType], either directly or indirectly. 1825 * implemented by the given [targetType], either directly or indirectly.
1810 * Return the element representing the setter that was found, or `null` if 1826 * Return the element representing the setter that was found, or `null` if
1811 * there is no setter with the given name. The [targetType] is the type in 1827 * there is no setter with the given name. The [targetType] is the type in
1812 * which the setter might be defined. The flag [includeTargetType] should be 1828 * which the setter might be defined. The flag [includeTargetType] should be
1813 * `true` if the search should include the target type. The 1829 * `true` if the search should include the target type. The
1814 * [visitedInterfaces] is a set containing all of the interfaces that have 1830 * [visitedInterfaces] is a set containing all of the interfaces that have
1815 * been examined, used to prevent infinite recursion and to optimize the 1831 * been examined, used to prevent infinite recursion and to optimize the
1816 * search. 1832 * search.
1817 */ 1833 */
1818 PropertyAccessorElement _lookUpSetterInInterfaces(InterfaceType targetType, 1834 PropertyAccessorElement _lookUpSetterInInterfaces(
1819 bool includeTargetType, String setterName, 1835 InterfaceType targetType,
1836 bool includeTargetType,
1837 String setterName,
1820 HashSet<ClassElement> visitedInterfaces) { 1838 HashSet<ClassElement> visitedInterfaces) {
1821 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the 1839 // TODO(brianwilkerson) This isn't correct. Section 8.1.1 of the
1822 // specification (titled "Inheritance and Overriding" under "Interfaces") 1840 // specification (titled "Inheritance and Overriding" under "Interfaces")
1823 // describes a much more complex scheme for finding the inherited member. 1841 // describes a much more complex scheme for finding the inherited member.
1824 // We need to follow that scheme. The code below should cover the 80% case. 1842 // We need to follow that scheme. The code below should cover the 80% case.
1825 ClassElement targetClass = targetType.element; 1843 ClassElement targetClass = targetType.element;
1826 if (visitedInterfaces.contains(targetClass)) { 1844 if (visitedInterfaces.contains(targetClass)) {
1827 return null; 1845 return null;
1828 } 1846 }
1829 visitedInterfaces.add(targetClass); 1847 visitedInterfaces.add(targetClass);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 if (nameNode1 != null && nameNode2 == null && nameNode3 == null) { 2023 if (nameNode1 != null && nameNode2 == null && nameNode3 == null) {
2006 Element element1 = nameNode1.staticElement; 2024 Element element1 = nameNode1.staticElement;
2007 // CONST 2025 // CONST
2008 if (element1 is PropertyAccessorElement) { 2026 if (element1 is PropertyAccessorElement) {
2009 _resolveAnnotationElementGetter(annotation, element1); 2027 _resolveAnnotationElementGetter(annotation, element1);
2010 return; 2028 return;
2011 } 2029 }
2012 // Class(args) 2030 // Class(args)
2013 if (element1 is ClassElement) { 2031 if (element1 is ClassElement) {
2014 ClassElement classElement = element1; 2032 ClassElement classElement = element1;
2015 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor( 2033 constructor = new InterfaceTypeImpl(classElement)
2016 null, _definingLibrary); 2034 .lookUpConstructor(null, _definingLibrary);
2017 } 2035 }
2018 } 2036 }
2019 // 2037 //
2020 // prefix.CONST or prefix.Class() or Class.CONST or Class.constructor(args) 2038 // prefix.CONST or prefix.Class() or Class.CONST or Class.constructor(args)
2021 // 2039 //
2022 if (nameNode1 != null && nameNode2 != null && nameNode3 == null) { 2040 if (nameNode1 != null && nameNode2 != null && nameNode3 == null) {
2023 Element element1 = nameNode1.staticElement; 2041 Element element1 = nameNode1.staticElement;
2024 Element element2 = nameNode2.staticElement; 2042 Element element2 = nameNode2.staticElement;
2025 // Class.CONST - not resolved yet 2043 // Class.CONST - not resolved yet
2026 if (element1 is ClassElement) { 2044 if (element1 is ClassElement) {
2027 ClassElement classElement = element1; 2045 ClassElement classElement = element1;
2028 element2 = classElement.lookUpGetter(nameNode2.name, _definingLibrary); 2046 element2 = classElement.lookUpGetter(nameNode2.name, _definingLibrary);
2029 } 2047 }
2030 // prefix.CONST or Class.CONST 2048 // prefix.CONST or Class.CONST
2031 if (element2 is PropertyAccessorElement) { 2049 if (element2 is PropertyAccessorElement) {
2032 nameNode2.staticElement = element2; 2050 nameNode2.staticElement = element2;
2033 annotation.element = element2; 2051 annotation.element = element2;
2034 _resolveAnnotationElementGetter(annotation, element2); 2052 _resolveAnnotationElementGetter(annotation, element2);
2035 return; 2053 return;
2036 } 2054 }
2037 // prefix.Class() 2055 // prefix.Class()
2038 if (element2 is ClassElement) { 2056 if (element2 is ClassElement) {
2039 constructor = element2.unnamedConstructor; 2057 constructor = element2.unnamedConstructor;
2040 } 2058 }
2041 // Class.constructor(args) 2059 // Class.constructor(args)
2042 if (element1 is ClassElement) { 2060 if (element1 is ClassElement) {
2043 ClassElement classElement = element1; 2061 ClassElement classElement = element1;
2044 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor( 2062 constructor = new InterfaceTypeImpl(classElement)
2045 nameNode2.name, _definingLibrary); 2063 .lookUpConstructor(nameNode2.name, _definingLibrary);
2046 nameNode2.staticElement = constructor; 2064 nameNode2.staticElement = constructor;
2047 } 2065 }
2048 } 2066 }
2049 // 2067 //
2050 // prefix.Class.CONST or prefix.Class.constructor(args) 2068 // prefix.Class.CONST or prefix.Class.constructor(args)
2051 // 2069 //
2052 if (nameNode1 != null && nameNode2 != null && nameNode3 != null) { 2070 if (nameNode1 != null && nameNode2 != null && nameNode3 != null) {
2053 Element element2 = nameNode2.staticElement; 2071 Element element2 = nameNode2.staticElement;
2054 // element2 should be ClassElement 2072 // element2 should be ClassElement
2055 if (element2 is ClassElement) { 2073 if (element2 is ClassElement) {
2056 ClassElement classElement = element2; 2074 ClassElement classElement = element2;
2057 String name3 = nameNode3.name; 2075 String name3 = nameNode3.name;
2058 // prefix.Class.CONST 2076 // prefix.Class.CONST
2059 PropertyAccessorElement getter = 2077 PropertyAccessorElement getter =
2060 classElement.lookUpGetter(name3, _definingLibrary); 2078 classElement.lookUpGetter(name3, _definingLibrary);
2061 if (getter != null) { 2079 if (getter != null) {
2062 nameNode3.staticElement = getter; 2080 nameNode3.staticElement = getter;
2063 annotation.element = element2; 2081 annotation.element = element2;
2064 _resolveAnnotationElementGetter(annotation, getter); 2082 _resolveAnnotationElementGetter(annotation, getter);
2065 return; 2083 return;
2066 } 2084 }
2067 // prefix.Class.constructor(args) 2085 // prefix.Class.constructor(args)
2068 constructor = new InterfaceTypeImpl(classElement).lookUpConstructor( 2086 constructor = new InterfaceTypeImpl(classElement)
2069 name3, _definingLibrary); 2087 .lookUpConstructor(name3, _definingLibrary);
2070 nameNode3.staticElement = constructor; 2088 nameNode3.staticElement = constructor;
2071 } 2089 }
2072 } 2090 }
2073 // we need constructor 2091 // we need constructor
2074 if (constructor == null) { 2092 if (constructor == null) {
2075 _resolver.reportErrorForNode( 2093 _resolver.reportErrorForNode(
2076 CompileTimeErrorCode.INVALID_ANNOTATION, annotation); 2094 CompileTimeErrorCode.INVALID_ANNOTATION, annotation);
2077 return; 2095 return;
2078 } 2096 }
2079 // record element 2097 // record element
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 if (unnamedIndex < unnamedParameterCount) { 2200 if (unnamedIndex < unnamedParameterCount) {
2183 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; 2201 resolvedParameters[i] = unnamedParameters[unnamedIndex++];
2184 } 2202 }
2185 } 2203 }
2186 } 2204 }
2187 if (positionalArgumentCount < requiredParameters.length && 2205 if (positionalArgumentCount < requiredParameters.length &&
2188 noBlankArguments) { 2206 noBlankArguments) {
2189 ErrorCode errorCode = (reportError 2207 ErrorCode errorCode = (reportError
2190 ? CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS 2208 ? CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS
2191 : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS); 2209 : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS);
2192 _resolver.reportErrorForNode(errorCode, argumentList, [ 2210 _resolver.reportErrorForNode(errorCode, argumentList,
2193 requiredParameters.length, 2211 [requiredParameters.length, positionalArgumentCount]);
2194 positionalArgumentCount
2195 ]);
2196 } else if (positionalArgumentCount > unnamedParameterCount && 2212 } else if (positionalArgumentCount > unnamedParameterCount &&
2197 noBlankArguments) { 2213 noBlankArguments) {
2198 ErrorCode errorCode = (reportError 2214 ErrorCode errorCode = (reportError
2199 ? CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS 2215 ? CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS
2200 : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS); 2216 : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS);
2201 _resolver.reportErrorForNode(errorCode, argumentList, [ 2217 _resolver.reportErrorForNode(errorCode, argumentList,
2202 unnamedParameterCount, 2218 [unnamedParameterCount, positionalArgumentCount]);
2203 positionalArgumentCount
2204 ]);
2205 } 2219 }
2206 return resolvedParameters; 2220 return resolvedParameters;
2207 } 2221 }
2208 2222
2209 void _resolveBinaryExpression(BinaryExpression node, String methodName) { 2223 void _resolveBinaryExpression(BinaryExpression node, String methodName) {
2210 Expression leftOperand = node.leftOperand; 2224 Expression leftOperand = node.leftOperand;
2211 if (leftOperand != null) { 2225 if (leftOperand != null) {
2212 DartType staticType = _getStaticType(leftOperand); 2226 DartType staticType = _getStaticType(leftOperand);
2213 MethodElement staticMethod = 2227 MethodElement staticMethod =
2214 _lookUpMethod(leftOperand, staticType, methodName); 2228 _lookUpMethod(leftOperand, staticType, methodName);
2215 node.staticElement = staticMethod; 2229 node.staticElement = staticMethod;
2216 DartType propagatedType = _getPropagatedType(leftOperand); 2230 DartType propagatedType = _getPropagatedType(leftOperand);
2217 MethodElement propagatedMethod = 2231 MethodElement propagatedMethod =
2218 _lookUpMethod(leftOperand, propagatedType, methodName); 2232 _lookUpMethod(leftOperand, propagatedType, methodName);
2219 node.propagatedElement = propagatedMethod; 2233 node.propagatedElement = propagatedMethod;
2220 if (_shouldReportMissingMember(staticType, staticMethod)) { 2234 if (_shouldReportMissingMember(staticType, staticMethod)) {
2221 if (leftOperand is SuperExpression) { 2235 if (leftOperand is SuperExpression) {
2222 _recordUndefinedToken(staticType.element, 2236 _recordUndefinedToken(
2223 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, node.operator, [ 2237 staticType.element,
2224 methodName, 2238 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR,
2225 staticType.displayName 2239 node.operator,
2226 ]); 2240 [methodName, staticType.displayName]);
2227 } else { 2241 } else {
2228 _recordUndefinedToken(staticType.element, 2242 _recordUndefinedToken(
2229 StaticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [ 2243 staticType.element,
2230 methodName, 2244 StaticTypeWarningCode.UNDEFINED_OPERATOR,
2231 staticType.displayName 2245 node.operator,
2232 ]); 2246 [methodName, staticType.displayName]);
2233 } 2247 }
2234 } else if (_enableHints && 2248 } else if (_enableHints &&
2235 _shouldReportMissingMember(propagatedType, propagatedMethod) && 2249 _shouldReportMissingMember(propagatedType, propagatedMethod) &&
2236 !_memberFoundInSubclass( 2250 !_memberFoundInSubclass(
2237 propagatedType.element, methodName, true, false)) { 2251 propagatedType.element, methodName, true, false)) {
2238 _recordUndefinedToken(propagatedType.element, 2252 _recordUndefinedToken(
2239 HintCode.UNDEFINED_OPERATOR, node.operator, [ 2253 propagatedType.element,
2240 methodName, 2254 HintCode.UNDEFINED_OPERATOR,
2241 propagatedType.displayName 2255 node.operator,
2242 ]); 2256 [methodName, propagatedType.displayName]);
2243 } 2257 }
2244 } 2258 }
2245 } 2259 }
2246 2260
2247 /** 2261 /**
2248 * Resolve the names in the given [combinators] in the scope of the given 2262 * Resolve the names in the given [combinators] in the scope of the given
2249 * [library]. 2263 * [library].
2250 */ 2264 */
2251 void _resolveCombinators( 2265 void _resolveCombinators(
2252 LibraryElement library, NodeList<Combinator> combinators) { 2266 LibraryElement library, NodeList<Combinator> combinators) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 // style of [lookUpMethod]. 2379 // style of [lookUpMethod].
2366 element = _lookUpGetter(target, targetType, methodName.name); 2380 element = _lookUpGetter(target, targetType, methodName.name);
2367 } 2381 }
2368 return element; 2382 return element;
2369 } else if (target is SimpleIdentifier) { 2383 } else if (target is SimpleIdentifier) {
2370 Element targetElement = target.staticElement; 2384 Element targetElement = target.staticElement;
2371 if (targetElement is PrefixElement) { 2385 if (targetElement is PrefixElement) {
2372 if (isConditional) { 2386 if (isConditional) {
2373 _resolver.reportErrorForNode( 2387 _resolver.reportErrorForNode(
2374 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 2388 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
2375 target, [target.name]); 2389 target,
2390 [target.name]);
2376 } 2391 }
2377 // 2392 //
2378 // Look to see whether the name of the method is really part of a 2393 // Look to see whether the name of the method is really part of a
2379 // prefixed identifier for an imported top-level function or top-level 2394 // prefixed identifier for an imported top-level function or top-level
2380 // getter that returns a function. 2395 // getter that returns a function.
2381 // 2396 //
2382 String name = "${target.name}.$methodName"; 2397 String name = "${target.name}.$methodName";
2383 Identifier functionName = new SyntheticIdentifier(name, methodName); 2398 Identifier functionName = new SyntheticIdentifier(name, methodName);
2384 Element element = 2399 Element element =
2385 _resolver.nameScope.lookup(functionName, _definingLibrary); 2400 _resolver.nameScope.lookup(functionName, _definingLibrary);
(...skipping 23 matching lines...) Expand all
2409 if (memberElement == null) { 2424 if (memberElement == null) {
2410 memberElement = _lookUpGetter(target, targetType, propertyName.name); 2425 memberElement = _lookUpGetter(target, targetType, propertyName.name);
2411 } 2426 }
2412 if (memberElement == null) { 2427 if (memberElement == null) {
2413 memberElement = _lookUpMethod(target, targetType, propertyName.name); 2428 memberElement = _lookUpMethod(target, targetType, propertyName.name);
2414 } 2429 }
2415 return memberElement; 2430 return memberElement;
2416 } 2431 }
2417 2432
2418 void _resolvePropertyAccess( 2433 void _resolvePropertyAccess(
2419 Expression target, SimpleIdentifier propertyName, bool isConditional) { 2434 Expression target, SimpleIdentifier propertyName) {
2420 DartType staticType = _getStaticType(target); 2435 DartType staticType = _getStaticType(target);
2421 DartType propagatedType = _getPropagatedType(target); 2436 DartType propagatedType = _getPropagatedType(target);
2422 Element staticElement = null; 2437 Element staticElement = null;
2423 Element propagatedElement = null; 2438 Element propagatedElement = null;
2424 // 2439 //
2425 // If this property access is of the form 'C.m' where 'C' is a class, 2440 // If this property access is of the form 'C.m' where 'C' is a class,
2426 // then we don't call resolveProperty(...) which walks up the class 2441 // then we don't call resolveProperty(...) which walks up the class
2427 // hierarchy, instead we just look for the member in the type only. This 2442 // hierarchy, instead we just look for the member in the type only. This
2428 // does not apply to conditional property accesses (i.e. 'C?.m'). 2443 // does not apply to conditional property accesses (i.e. 'C?.m').
2429 // 2444 //
2430 ClassElementImpl typeReference = getTypeReference(target, isConditional); 2445 ClassElementImpl typeReference = getTypeReference(target);
2431 if (typeReference != null) { 2446 if (typeReference != null) {
2432 // TODO(brianwilkerson) Why are we setting the propagated element here? 2447 // TODO(brianwilkerson) Why are we setting the propagated element here?
2433 // It looks wrong. 2448 // It looks wrong.
2434 staticElement = 2449 staticElement =
2435 propagatedElement = _resolveElement(typeReference, propertyName); 2450 propagatedElement = _resolveElement(typeReference, propertyName);
2436 } else { 2451 } else {
2437 staticElement = _resolveProperty(target, staticType, propertyName); 2452 staticElement = _resolveProperty(target, staticType, propertyName);
2438 propagatedElement = 2453 propagatedElement =
2439 _resolveProperty(target, propagatedType, propertyName); 2454 _resolveProperty(target, propagatedType, propertyName);
2440 } 2455 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 if (!_enableStrictCallChecks && 2489 if (!_enableStrictCallChecks &&
2475 targetType != null && 2490 targetType != null &&
2476 targetType.isDartCoreFunction && 2491 targetType.isDartCoreFunction &&
2477 propertyName.name == FunctionElement.CALL_METHOD_NAME) { 2492 propertyName.name == FunctionElement.CALL_METHOD_NAME) {
2478 // TODO(brianwilkerson) Can we ever resolve the function being 2493 // TODO(brianwilkerson) Can we ever resolve the function being
2479 // invoked? 2494 // invoked?
2480 // resolveArgumentsToParameters(node.getArgumentList(), invokedFuncti on); 2495 // resolveArgumentsToParameters(node.getArgumentList(), invokedFuncti on);
2481 return; 2496 return;
2482 } else if (classElement.isEnum && propertyName.name == "_name") { 2497 } else if (classElement.isEnum && propertyName.name == "_name") {
2483 _resolver.reportErrorForNode( 2498 _resolver.reportErrorForNode(
2484 CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD, propertyName, 2499 CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD,
2500 propertyName,
2485 [propertyName.name]); 2501 [propertyName.name]);
2486 return; 2502 return;
2487 } 2503 }
2488 } 2504 }
2489 } 2505 }
2490 Element declaringElement = 2506 Element declaringElement =
2491 staticType.isVoid ? null : staticOrPropagatedEnclosingElt; 2507 staticType.isVoid ? null : staticOrPropagatedEnclosingElt;
2492 if (propertyName.inSetterContext()) { 2508 if (propertyName.inSetterContext()) {
2493 ErrorCode errorCode; 2509 ErrorCode errorCode;
2494 if (shouldReportMissingMember_static) { 2510 if (shouldReportMissingMember_static) {
2495 if (target is SuperExpression) { 2511 if (target is SuperExpression) {
2496 if (isStaticProperty && !staticType.isVoid) { 2512 if (isStaticProperty && !staticType.isVoid) {
2497 errorCode = StaticWarningCode.UNDEFINED_SUPER_SETTER; 2513 errorCode = StaticWarningCode.UNDEFINED_SUPER_SETTER;
2498 } else { 2514 } else {
2499 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_SETTER; 2515 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_SETTER;
2500 } 2516 }
2501 } else { 2517 } else {
2502 if (isStaticProperty && !staticType.isVoid) { 2518 if (isStaticProperty && !staticType.isVoid) {
2503 errorCode = StaticWarningCode.UNDEFINED_SETTER; 2519 errorCode = StaticWarningCode.UNDEFINED_SETTER;
2504 } else { 2520 } else {
2505 errorCode = StaticTypeWarningCode.UNDEFINED_SETTER; 2521 errorCode = StaticTypeWarningCode.UNDEFINED_SETTER;
2506 } 2522 }
2507 } 2523 }
2508 } else { 2524 } else {
2509 errorCode = HintCode.UNDEFINED_SETTER; 2525 errorCode = HintCode.UNDEFINED_SETTER;
2510 } 2526 }
2511 _recordUndefinedNode(declaringElement, errorCode, propertyName, [ 2527 _recordUndefinedNode(declaringElement, errorCode, propertyName,
2512 propertyName.name, 2528 [propertyName.name, displayType.displayName]);
2513 displayType.displayName
2514 ]);
2515 } else if (propertyName.inGetterContext()) { 2529 } else if (propertyName.inGetterContext()) {
2516 ErrorCode errorCode; 2530 ErrorCode errorCode;
2517 if (shouldReportMissingMember_static) { 2531 if (shouldReportMissingMember_static) {
2518 if (target is SuperExpression) { 2532 if (target is SuperExpression) {
2519 if (isStaticProperty && !staticType.isVoid) { 2533 if (isStaticProperty && !staticType.isVoid) {
2520 errorCode = StaticWarningCode.UNDEFINED_SUPER_GETTER; 2534 errorCode = StaticWarningCode.UNDEFINED_SUPER_GETTER;
2521 } else { 2535 } else {
2522 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_GETTER; 2536 errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_GETTER;
2523 } 2537 }
2524 } else { 2538 } else {
2525 if (isStaticProperty && !staticType.isVoid) { 2539 if (isStaticProperty && !staticType.isVoid) {
2526 errorCode = StaticWarningCode.UNDEFINED_GETTER; 2540 errorCode = StaticWarningCode.UNDEFINED_GETTER;
2527 } else { 2541 } else {
2528 errorCode = StaticTypeWarningCode.UNDEFINED_GETTER; 2542 errorCode = StaticTypeWarningCode.UNDEFINED_GETTER;
2529 } 2543 }
2530 } 2544 }
2531 } else { 2545 } else {
2532 errorCode = HintCode.UNDEFINED_GETTER; 2546 errorCode = HintCode.UNDEFINED_GETTER;
2533 } 2547 }
2534 _recordUndefinedNode(declaringElement, errorCode, propertyName, [ 2548 _recordUndefinedNode(declaringElement, errorCode, propertyName,
2535 propertyName.name, 2549 [propertyName.name, displayType.displayName]);
2536 displayType.displayName
2537 ]);
2538 } else { 2550 } else {
2539 _recordUndefinedNode(declaringElement, 2551 _recordUndefinedNode(
2540 StaticWarningCode.UNDEFINED_IDENTIFIER, propertyName, 2552 declaringElement,
2553 StaticWarningCode.UNDEFINED_IDENTIFIER,
2554 propertyName,
2541 [propertyName.name]); 2555 [propertyName.name]);
2542 } 2556 }
2543 } 2557 }
2544 } 2558 }
2545 2559
2546 /** 2560 /**
2547 * Resolve the given simple [identifier] if possible. Return the element to 2561 * Resolve the given simple [identifier] if possible. Return the element to
2548 * which it could be resolved, or `null` if it could not be resolved. This 2562 * which it could be resolved, or `null` if it could not be resolved. This
2549 * does not record the results of the resolution. 2563 * does not record the results of the resolution.
2550 */ 2564 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 bool _shouldReportMissingMember(DartType type, Element member) { 2647 bool _shouldReportMissingMember(DartType type, Element member) {
2634 if (member != null || type == null || type.isDynamic || type.isBottom) { 2648 if (member != null || type == null || type.isDynamic || type.isBottom) {
2635 return false; 2649 return false;
2636 } 2650 }
2637 return true; 2651 return true;
2638 } 2652 }
2639 2653
2640 /** 2654 /**
2641 * Checks whether the given [expression] is a reference to a class. If it is 2655 * Checks whether the given [expression] is a reference to a class. If it is
2642 * then the element representing the class is returned, otherwise `null` is 2656 * then the element representing the class is returned, otherwise `null` is
2643 * returned. [isConditional] indicates whether [expression] is to the left 2657 * returned.
2644 * of a '?.' opertator.
2645 */ 2658 */
2646 static ClassElementImpl getTypeReference( 2659 static ClassElementImpl getTypeReference(Expression expression) {
2647 Expression expression, bool isConditional) { 2660 if (expression is Identifier) {
2648 if (!isConditional && expression is Identifier) {
2649 Element staticElement = expression.staticElement; 2661 Element staticElement = expression.staticElement;
2650 if (staticElement is ClassElementImpl) { 2662 if (staticElement is ClassElementImpl) {
2651 return staticElement; 2663 return staticElement;
2652 } 2664 }
2653 } 2665 }
2654 return null; 2666 return null;
2655 } 2667 }
2656 2668
2657 /** 2669 /**
2658 * Given a [node] that can have annotations associated with it and the 2670 * Given a [node] that can have annotations associated with it and the
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2803 2815
2804 @override 2816 @override
2805 Element get staticElement => null; 2817 Element get staticElement => null;
2806 2818
2807 @override 2819 @override
2808 accept(AstVisitor visitor) => null; 2820 accept(AstVisitor visitor) => null;
2809 2821
2810 @override 2822 @override
2811 void visitChildren(AstVisitor visitor) {} 2823 void visitChildren(AstVisitor visitor) {}
2812 } 2824 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/generated/element_handle.dart ('k') | packages/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698