| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.generated.element_resolver; | 5 library analyzer.src.generated.element_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; | 10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 propagatedElement = null; | 619 propagatedElement = null; |
| 620 } else if (methodName.name == FunctionElement.LOAD_LIBRARY_NAME && | 620 } else if (methodName.name == FunctionElement.LOAD_LIBRARY_NAME && |
| 621 _isDeferredPrefix(target)) { | 621 _isDeferredPrefix(target)) { |
| 622 if (node.operator.type == TokenType.QUESTION_PERIOD) { | 622 if (node.operator.type == TokenType.QUESTION_PERIOD) { |
| 623 _resolver.errorReporter.reportErrorForNode( | 623 _resolver.errorReporter.reportErrorForNode( |
| 624 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, | 624 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, |
| 625 target, | 625 target, |
| 626 [(target as SimpleIdentifier).name]); | 626 [(target as SimpleIdentifier).name]); |
| 627 } | 627 } |
| 628 LibraryElement importedLibrary = _getImportedLibrary(target); | 628 LibraryElement importedLibrary = _getImportedLibrary(target); |
| 629 FunctionElement loadLibraryFunction = importedLibrary.loadLibraryFunction; | 629 FunctionElement loadLibraryFunction = |
| 630 importedLibrary?.loadLibraryFunction; |
| 630 methodName.staticElement = loadLibraryFunction; | 631 methodName.staticElement = loadLibraryFunction; |
| 631 node.staticInvokeType = loadLibraryFunction.type; | 632 node.staticInvokeType = loadLibraryFunction.type; |
| 632 return null; | 633 return null; |
| 633 } else { | 634 } else { |
| 634 // | 635 // |
| 635 // If this method invocation is of the form 'C.m' where 'C' is a class, | 636 // If this method invocation is of the form 'C.m' where 'C' is a class, |
| 636 // then we don't call resolveInvokedElement(...) which walks up the class | 637 // then we don't call resolveInvokedElement(...) which walks up the class |
| 637 // hierarchy, instead we just look for the member in the type only. This | 638 // hierarchy, instead we just look for the member in the type only. This |
| 638 // does not apply to conditional method invocation (i.e. 'C?.m(...)'). | 639 // does not apply to conditional method invocation (i.e. 'C?.m(...)'). |
| 639 // | 640 // |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 @override | 888 @override |
| 888 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 889 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 889 SimpleIdentifier prefix = node.prefix; | 890 SimpleIdentifier prefix = node.prefix; |
| 890 SimpleIdentifier identifier = node.identifier; | 891 SimpleIdentifier identifier = node.identifier; |
| 891 // | 892 // |
| 892 // First, check the "lib.loadLibrary" case | 893 // First, check the "lib.loadLibrary" case |
| 893 // | 894 // |
| 894 if (identifier.name == FunctionElement.LOAD_LIBRARY_NAME && | 895 if (identifier.name == FunctionElement.LOAD_LIBRARY_NAME && |
| 895 _isDeferredPrefix(prefix)) { | 896 _isDeferredPrefix(prefix)) { |
| 896 LibraryElement importedLibrary = _getImportedLibrary(prefix); | 897 LibraryElement importedLibrary = _getImportedLibrary(prefix); |
| 897 identifier.staticElement = importedLibrary.loadLibraryFunction; | 898 identifier.staticElement = importedLibrary?.loadLibraryFunction; |
| 898 return null; | 899 return null; |
| 899 } | 900 } |
| 900 // | 901 // |
| 901 // Check to see whether the prefix is really a prefix. | 902 // Check to see whether the prefix is really a prefix. |
| 902 // | 903 // |
| 903 Element prefixElement = prefix.staticElement; | 904 Element prefixElement = prefix.staticElement; |
| 904 if (prefixElement is PrefixElement) { | 905 if (prefixElement is PrefixElement) { |
| 905 Element element = _resolver.nameScope.lookup(node, _definingLibrary); | 906 Element element = _resolver.nameScope.lookup(node, _definingLibrary); |
| 906 if (element == null && identifier.inSetterContext()) { | 907 if (element == null && identifier.inSetterContext()) { |
| 907 Identifier setterName = new PrefixedIdentifierImpl.temp( | 908 Identifier setterName = new PrefixedIdentifierImpl.temp( |
| (...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2648 | 2649 |
| 2649 @override | 2650 @override |
| 2650 Element get staticElement => null; | 2651 Element get staticElement => null; |
| 2651 | 2652 |
| 2652 @override | 2653 @override |
| 2653 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; | 2654 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; |
| 2654 | 2655 |
| 2655 @override | 2656 @override |
| 2656 void visitChildren(AstVisitor visitor) {} | 2657 void visitChildren(AstVisitor visitor) {} |
| 2657 } | 2658 } |
| OLD | NEW |