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); |
1034 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { | 1035 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu
ll) { |
1035 InterfaceType enclosingType = enclosingClass.type; | 1036 InterfaceType enclosingType = enclosingClass.type; |
1036 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter(
null, enclosingType, node.name), null); | 1037 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter(
null, enclosingType, node.name), null); |
1037 node.auxiliaryElements = auxiliaryElements; | 1038 node.auxiliaryElements = auxiliaryElements; |
1038 } | 1039 } |
1039 // | 1040 // |
1040 // Validate annotation element. | 1041 // Validate annotation element. |
1041 // | 1042 // |
1042 if (node.parent is Annotation) { | 1043 if (node.parent is Annotation) { |
1043 Annotation annotation = node.parent as Annotation; | 1044 Annotation annotation = node.parent as Annotation; |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 } | 1896 } |
1896 } | 1897 } |
1897 InterfaceType superclass = targetType.superclass; | 1898 InterfaceType superclass = targetType.superclass; |
1898 if (superclass == null) { | 1899 if (superclass == null) { |
1899 return null; | 1900 return null; |
1900 } | 1901 } |
1901 return _lookUpSetterInInterfaces(superclass, true, setterName, visitedInterf
aces); | 1902 return _lookUpSetterInInterfaces(superclass, true, setterName, visitedInterf
aces); |
1902 } | 1903 } |
1903 | 1904 |
1904 /** | 1905 /** |
| 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 /** |
1905 * Given some class element, this method uses [subtypeManager] to find the set
of all | 1929 * Given some class element, this method uses [subtypeManager] to find the set
of all |
1906 * subtypes; the subtypes are then searched for a member (method, getter, or s
etter), that matches | 1930 * subtypes; the subtypes are then searched for a member (method, getter, or s
etter), that matches |
1907 * a passed | 1931 * a passed |
1908 * | 1932 * |
1909 * @param element the class element to search the subtypes of, if a non-ClassE
lement element is | 1933 * @param element the class element to search the subtypes of, if a non-ClassE
lement element is |
1910 * passed, then `false` is returned | 1934 * passed, then `false` is returned |
1911 * @param memberName the member name to search for | 1935 * @param memberName the member name to search for |
1912 * @param asMethod `true` if the methods should be searched for in the subtype
s | 1936 * @param asMethod `true` if the methods should be searched for in the subtype
s |
1913 * @param asAccessor `true` if the accessors (getters and setters) should be s
earched for in | 1937 * @param asAccessor `true` if the accessors (getters and setters) should be s
earched for in |
1914 * the subtypes | 1938 * the subtypes |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 @override | 2670 @override |
2647 Element get propagatedElement => null; | 2671 Element get propagatedElement => null; |
2648 | 2672 |
2649 @override | 2673 @override |
2650 Element get staticElement => null; | 2674 Element get staticElement => null; |
2651 | 2675 |
2652 @override | 2676 @override |
2653 void visitChildren(AstVisitor visitor) { | 2677 void visitChildren(AstVisitor visitor) { |
2654 } | 2678 } |
2655 } | 2679 } |
OLD | NEW |