| 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 engine.resolver.element_resolver; | 5 library engine.resolver.element_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'scanner.dart' as sc; | 10 import 'scanner.dart' as sc; |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 if (_isConstructorReturnType(node)) { | 1024 if (_isConstructorReturnType(node)) { |
| 1025 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NA
ME, node); | 1025 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NA
ME, node); |
| 1026 } else if (node.parent is Annotation) { | 1026 } else if (node.parent is Annotation) { |
| 1027 Annotation annotation = node.parent as Annotation; | 1027 Annotation annotation = node.parent as Annotation; |
| 1028 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, an
notation); | 1028 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, an
notation); |
| 1029 } else { | 1029 } else { |
| 1030 _recordUndefinedNode(_resolver.enclosingClass, StaticWarningCode.UNDEFIN
ED_IDENTIFIER, node, [node.name]); | 1030 _recordUndefinedNode(_resolver.enclosingClass, StaticWarningCode.UNDEFIN
ED_IDENTIFIER, node, [node.name]); |
| 1031 } | 1031 } |
| 1032 } | 1032 } |
| 1033 node.staticElement = element; | 1033 node.staticElement = element; |
| 1034 _markElementUsed(element); | |
| 1035 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { | 1034 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { |
| 1036 InterfaceType enclosingType = enclosingClass.type; | 1035 InterfaceType enclosingType = enclosingClass.type; |
| 1037 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter(
null, enclosingType, node.name), null); | 1036 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter(
null, enclosingType, node.name), null); |
| 1038 node.auxiliaryElements = auxiliaryElements; | 1037 node.auxiliaryElements = auxiliaryElements; |
| 1039 } | 1038 } |
| 1040 // | 1039 // |
| 1041 // Validate annotation element. | 1040 // Validate annotation element. |
| 1042 // | 1041 // |
| 1043 if (node.parent is Annotation) { | 1042 if (node.parent is Annotation) { |
| 1044 Annotation annotation = node.parent as Annotation; | 1043 Annotation annotation = node.parent as Annotation; |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 } | 1895 } |
| 1897 } | 1896 } |
| 1898 InterfaceType superclass = targetType.superclass; | 1897 InterfaceType superclass = targetType.superclass; |
| 1899 if (superclass == null) { | 1898 if (superclass == null) { |
| 1900 return null; | 1899 return null; |
| 1901 } | 1900 } |
| 1902 return _lookUpSetterInInterfaces(superclass, true, setterName, visitedInterf
aces); | 1901 return _lookUpSetterInInterfaces(superclass, true, setterName, visitedInterf
aces); |
| 1903 } | 1902 } |
| 1904 | 1903 |
| 1905 /** | 1904 /** |
| 1906 * Marks [element] as used in its defining library. | |
| 1907 */ | |
| 1908 void _markElementUsed(Element element) { | |
| 1909 // only locally defined elements | |
| 1910 if (element == null) { | |
| 1911 return; | |
| 1912 } | |
| 1913 if (!identical(element.library, _definingLibrary)) { | |
| 1914 return; | |
| 1915 } | |
| 1916 // convert members to base elements | |
| 1917 if (element is Member) { | |
| 1918 element = (element as Member).baseElement; | |
| 1919 } | |
| 1920 // ignore references to an element from itself | |
| 1921 if (identical(element, _resolver.enclosingClass)) { | |
| 1922 return; | |
| 1923 } | |
| 1924 // OK, the element is used | |
| 1925 (element as ElementImpl).markUsed(); | |
| 1926 } | |
| 1927 | |
| 1928 /** | |
| 1929 * Given some class element, this method uses [subtypeManager] to find the set
of all | 1905 * Given some class element, this method uses [subtypeManager] to find the set
of all |
| 1930 * subtypes; the subtypes are then searched for a member (method, getter, or s
etter), that matches | 1906 * subtypes; the subtypes are then searched for a member (method, getter, or s
etter), that matches |
| 1931 * a passed | 1907 * a passed |
| 1932 * | 1908 * |
| 1933 * @param element the class element to search the subtypes of, if a non-ClassE
lement element is | 1909 * @param element the class element to search the subtypes of, if a non-ClassE
lement element is |
| 1934 * passed, then `false` is returned | 1910 * passed, then `false` is returned |
| 1935 * @param memberName the member name to search for | 1911 * @param memberName the member name to search for |
| 1936 * @param asMethod `true` if the methods should be searched for in the subtype
s | 1912 * @param asMethod `true` if the methods should be searched for in the subtype
s |
| 1937 * @param asAccessor `true` if the accessors (getters and setters) should be s
earched for in | 1913 * @param asAccessor `true` if the accessors (getters and setters) should be s
earched for in |
| 1938 * the subtypes | 1914 * the subtypes |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 @override | 2646 @override |
| 2671 Element get propagatedElement => null; | 2647 Element get propagatedElement => null; |
| 2672 | 2648 |
| 2673 @override | 2649 @override |
| 2674 Element get staticElement => null; | 2650 Element get staticElement => null; |
| 2675 | 2651 |
| 2676 @override | 2652 @override |
| 2677 void visitChildren(AstVisitor visitor) { | 2653 void visitChildren(AstVisitor visitor) { |
| 2678 } | 2654 } |
| 2679 } | 2655 } |
| OLD | NEW |