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

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

Issue 1186033004: Update analyzer to reflect new rules for prefixes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 672 }
673 } 673 }
674 } 674 }
675 } 675 }
676 generatedWithTypePropagation = true; 676 generatedWithTypePropagation = true;
677 } 677 }
678 if (errorCode == null) { 678 if (errorCode == null) {
679 return null; 679 return null;
680 } 680 }
681 if (identical( 681 if (identical(
682 errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION)) { 682 errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION) ||
683 _resolver.reportErrorForNode( 683 identical(errorCode,
684 StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName, 684 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT) ||
685 [methodName.name]); 685 identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) {
686 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) { 686 _resolver.reportErrorForNode(errorCode, methodName, [methodName.name]);
687 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_FUNCTION,
688 methodName, [methodName.name]);
689 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { 687 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) {
690 String targetTypeName; 688 String targetTypeName;
691 if (target == null) { 689 if (target == null) {
692 ClassElement enclosingClass = _resolver.enclosingClass; 690 ClassElement enclosingClass = _resolver.enclosingClass;
693 targetTypeName = enclosingClass.displayName; 691 targetTypeName = enclosingClass.displayName;
694 ErrorCode proxyErrorCode = (generatedWithTypePropagation 692 ErrorCode proxyErrorCode = (generatedWithTypePropagation
695 ? HintCode.UNDEFINED_METHOD 693 ? HintCode.UNDEFINED_METHOD
696 : StaticTypeWarningCode.UNDEFINED_METHOD); 694 : StaticTypeWarningCode.UNDEFINED_METHOD);
697 _recordUndefinedNode(_resolver.enclosingClass, proxyErrorCode, 695 _recordUndefinedNode(_resolver.enclosingClass, proxyErrorCode,
698 methodName, [methodName.name, targetTypeName]); 696 methodName, [methodName.name, targetTypeName]);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 * Given that we have found code to invoke the given [element], return the 1107 * Given that we have found code to invoke the given [element], return the
1110 * error code that should be reported, or `null` if no error should be 1108 * error code that should be reported, or `null` if no error should be
1111 * reported. The [target] is the target of the invocation, or `null` if there 1109 * reported. The [target] is the target of the invocation, or `null` if there
1112 * was no target. The flag [useStaticContext] should be `true` if the 1110 * was no target. The flag [useStaticContext] should be `true` if the
1113 * invocation is in a static constant (does not have access to instance state. 1111 * invocation is in a static constant (does not have access to instance state.
1114 */ 1112 */
1115 ErrorCode _checkForInvocationError( 1113 ErrorCode _checkForInvocationError(
1116 Expression target, bool useStaticContext, Element element) { 1114 Expression target, bool useStaticContext, Element element) {
1117 // Prefix is not declared, instead "prefix.id" are declared. 1115 // Prefix is not declared, instead "prefix.id" are declared.
1118 if (element is PrefixElement) { 1116 if (element is PrefixElement) {
1119 element = null; 1117 return CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT;
1120 } 1118 }
1121 if (element is PropertyAccessorElement) { 1119 if (element is PropertyAccessorElement) {
1122 // 1120 //
1123 // This is really a function expression invocation. 1121 // This is really a function expression invocation.
1124 // 1122 //
1125 // TODO(brianwilkerson) Consider the possibility of re-writing the AST. 1123 // TODO(brianwilkerson) Consider the possibility of re-writing the AST.
1126 FunctionType getterType = element.type; 1124 FunctionType getterType = element.type;
1127 if (getterType != null) { 1125 if (getterType != null) {
1128 DartType returnType = getterType.returnType; 1126 DartType returnType = getterType.returnType;
1129 if (!_isExecutableType(returnType)) { 1127 if (!_isExecutableType(returnType)) {
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 * will be invoked. If the returned element is a getter, the getter will be 2313 * will be invoked. If the returned element is a getter, the getter will be
2316 * invoked without arguments and the result of that invocation will then be 2314 * invoked without arguments and the result of that invocation will then be
2317 * invoked with the arguments. The [methodName] is the name of the method 2315 * invoked with the arguments. The [methodName] is the name of the method
2318 * being invoked ('m'). 2316 * being invoked ('m').
2319 */ 2317 */
2320 Element _resolveInvokedElement(SimpleIdentifier methodName) { 2318 Element _resolveInvokedElement(SimpleIdentifier methodName) {
2321 // 2319 //
2322 // Look first in the lexical scope. 2320 // Look first in the lexical scope.
2323 // 2321 //
2324 Element element = _resolver.nameScope.lookup(methodName, _definingLibrary); 2322 Element element = _resolver.nameScope.lookup(methodName, _definingLibrary);
2325 if (element == null || element is PrefixElement) { 2323 if (element == null) {
2326 // 2324 //
2327 // If it isn't defined in the lexical scope, and the invocation is within 2325 // If it isn't defined in the lexical scope, and the invocation is within
2328 // a class, then look in the inheritance scope. 2326 // a class, then look in the inheritance scope.
2329 // 2327 //
2330 ClassElement enclosingClass = _resolver.enclosingClass; 2328 ClassElement enclosingClass = _resolver.enclosingClass;
2331 if (enclosingClass != null) { 2329 if (enclosingClass != null) {
2332 InterfaceType enclosingType = enclosingClass.type; 2330 InterfaceType enclosingType = enclosingClass.type;
2333 element = _lookUpMethod(null, enclosingType, methodName.name); 2331 element = _lookUpMethod(null, enclosingType, methodName.name);
2334 if (element == null) { 2332 if (element == null) {
2335 // 2333 //
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 if (setter != null) { 2568 if (setter != null) {
2571 element = setter; 2569 element = setter;
2572 } 2570 }
2573 } 2571 }
2574 } else if (element == null && 2572 } else if (element == null &&
2575 (identifier.inSetterContext() || 2573 (identifier.inSetterContext() ||
2576 identifier.parent is CommentReference)) { 2574 identifier.parent is CommentReference)) {
2577 element = _resolver.nameScope.lookup( 2575 element = _resolver.nameScope.lookup(
2578 new SyntheticIdentifier("${identifier.name}=", identifier), 2576 new SyntheticIdentifier("${identifier.name}=", identifier),
2579 _definingLibrary); 2577 _definingLibrary);
2580 } else if (element is PrefixElement && !identifier.inGetterContext()) {
2581 element = _resolver.nameScope.lookup(
2582 new SyntheticIdentifier("${identifier.name}=", identifier),
2583 _definingLibrary);
2584 } 2578 }
2585 ClassElement enclosingClass = _resolver.enclosingClass; 2579 ClassElement enclosingClass = _resolver.enclosingClass;
2586 if (element == null && enclosingClass != null) { 2580 if (element == null && enclosingClass != null) {
2587 InterfaceType enclosingType = enclosingClass.type; 2581 InterfaceType enclosingType = enclosingClass.type;
2588 if (element == null && 2582 if (element == null &&
2589 (identifier.inSetterContext() || 2583 (identifier.inSetterContext() ||
2590 identifier.parent is CommentReference)) { 2584 identifier.parent is CommentReference)) {
2591 element = _lookUpSetter(null, enclosingType, identifier.name); 2585 element = _lookUpSetter(null, enclosingType, identifier.name);
2592 } 2586 }
2593 if (element == null && identifier.inGetterContext()) { 2587 if (element == null && identifier.inGetterContext()) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 2803
2810 @override 2804 @override
2811 Element get staticElement => null; 2805 Element get staticElement => null;
2812 2806
2813 @override 2807 @override
2814 accept(AstVisitor visitor) => null; 2808 accept(AstVisitor visitor) => null;
2815 2809
2816 @override 2810 @override
2817 void visitChildren(AstVisitor visitor) {} 2811 void visitChildren(AstVisitor visitor) {}
2818 } 2812 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698