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) { | |
Brian Wilkerson
2014/11/10 23:34:47
This seems overly complex. Would it be sufficient
scheglov
2014/11/11 02:57:06
Done.
| |
1909 if (identical(element, _resolver.enclosingClass)) { | |
1910 return; | |
1911 } | |
1912 if (element is ElementImpl && | |
1913 element.enclosingElement is CompilationUnitElement && | |
1914 identical(element.library, _definingLibrary)) { | |
1915 element.markUsed(); | |
1916 } | |
1917 } | |
1918 | |
1919 /** | |
1905 * Given some class element, this method uses [subtypeManager] to find the set of all | 1920 * 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 | 1921 * subtypes; the subtypes are then searched for a member (method, getter, or s etter), that matches |
1907 * a passed | 1922 * a passed |
1908 * | 1923 * |
1909 * @param element the class element to search the subtypes of, if a non-ClassE lement element is | 1924 * @param element the class element to search the subtypes of, if a non-ClassE lement element is |
1910 * passed, then `false` is returned | 1925 * passed, then `false` is returned |
1911 * @param memberName the member name to search for | 1926 * @param memberName the member name to search for |
1912 * @param asMethod `true` if the methods should be searched for in the subtype s | 1927 * @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 | 1928 * @param asAccessor `true` if the accessors (getters and setters) should be s earched for in |
1914 * the subtypes | 1929 * the subtypes |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2646 @override | 2661 @override |
2647 Element get propagatedElement => null; | 2662 Element get propagatedElement => null; |
2648 | 2663 |
2649 @override | 2664 @override |
2650 Element get staticElement => null; | 2665 Element get staticElement => null; |
2651 | 2666 |
2652 @override | 2667 @override |
2653 void visitChildren(AstVisitor visitor) { | 2668 void visitChildren(AstVisitor visitor) { |
2654 } | 2669 } |
2655 } | 2670 } |
OLD | NEW |