| 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 // This code was auto-generated, is not intended to be edited, and is subject to | |
| 6 // significant change. Please see the README file for more information. | |
| 7 | |
| 8 library engine.element; | 5 library engine.element; |
| 9 | 6 |
| 10 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; |
| 11 | 9 |
| 12 import 'package:analyzer/src/generated/utilities_general.dart'; | 10 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 13 import 'package:analyzer/src/task/dart.dart'; | 11 import 'package:analyzer/src/task/dart.dart'; |
| 14 import 'package:analyzer/task/model.dart' | 12 import 'package:analyzer/task/model.dart' |
| 15 show AnalysisTarget, ConstantEvaluationTarget; | 13 show AnalysisTarget, ConstantEvaluationTarget; |
| 16 | 14 |
| 17 import 'ast.dart'; | 15 import 'ast.dart'; |
| 18 import 'constant.dart' show EvaluationResultImpl; | 16 import 'constant.dart' show EvaluationResultImpl; |
| 19 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; | 17 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; |
| 20 import 'html.dart' show XmlAttributeNode, XmlTagNode; | 18 import 'html.dart' show XmlAttributeNode, XmlTagNode; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 int get hashCode => 0; | 76 int get hashCode => 0; |
| 79 | 77 |
| 80 @override | 78 @override |
| 81 bool get isBottom => true; | 79 bool get isBottom => true; |
| 82 | 80 |
| 83 @override | 81 @override |
| 84 bool operator ==(Object object) => identical(object, this); | 82 bool operator ==(Object object) => identical(object, this); |
| 85 | 83 |
| 86 @override | 84 @override |
| 87 bool isMoreSpecificThan(DartType type, | 85 bool isMoreSpecificThan(DartType type, |
| 88 [bool withDynamic = false, Set<Element> visitedElements]) => true; | 86 [bool withDynamic = false, Set<Element> visitedElements]) => |
| 87 true; |
| 89 | 88 |
| 90 @override | 89 @override |
| 91 bool isSubtypeOf(DartType type) => true; | 90 bool isSubtypeOf(DartType type) => true; |
| 92 | 91 |
| 93 @override | 92 @override |
| 94 bool isSupertypeOf(DartType type) => false; | 93 bool isSupertypeOf(DartType type) => false; |
| 95 | 94 |
| 96 @override | 95 @override |
| 97 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; | 96 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; |
| 98 | 97 |
| 99 @override | 98 @override |
| 100 BottomTypeImpl substitute2( | 99 BottomTypeImpl substitute2( |
| 101 List<DartType> argumentTypes, List<DartType> parameterTypes, | 100 List<DartType> argumentTypes, List<DartType> parameterTypes, |
| 102 [List<FunctionTypeAliasElement> prune]) => this; | 101 [List<FunctionTypeAliasElement> prune]) => |
| 102 this; |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Type created internally if a circular reference is ever detected. Behaves | 106 * Type created internally if a circular reference is ever detected. Behaves |
| 107 * like `dynamic`, except that when converted to a string it is displayed as | 107 * like `dynamic`, except that when converted to a string it is displayed as |
| 108 * `...`. | 108 * `...`. |
| 109 */ | 109 */ |
| 110 class CircularTypeImpl extends DynamicTypeImpl { | 110 class CircularTypeImpl extends DynamicTypeImpl { |
| 111 CircularTypeImpl() : super._circular(); | 111 CircularTypeImpl() : super._circular(); |
| 112 | 112 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 * A list containing all of the type parameters defined for this class. | 547 * A list containing all of the type parameters defined for this class. |
| 548 */ | 548 */ |
| 549 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; | 549 List<TypeParameterElement> _typeParameters = TypeParameterElement.EMPTY_LIST; |
| 550 | 550 |
| 551 /** | 551 /** |
| 552 * The [SourceRange] of the `with` clause, `null` if there is no one. | 552 * The [SourceRange] of the `with` clause, `null` if there is no one. |
| 553 */ | 553 */ |
| 554 SourceRange withClauseRange; | 554 SourceRange withClauseRange; |
| 555 | 555 |
| 556 /** | 556 /** |
| 557 * A flag indicating whether the types associated with the instance members of |
| 558 * this class have been inferred. |
| 559 */ |
| 560 bool hasBeenInferred = false; |
| 561 |
| 562 /** |
| 557 * Initialize a newly created class element to have the given [name] at the | 563 * Initialize a newly created class element to have the given [name] at the |
| 558 * given [offset] in the file that contains the declaration of this element. | 564 * given [offset] in the file that contains the declaration of this element. |
| 559 */ | 565 */ |
| 560 ClassElementImpl(String name, int offset) : super(name, offset); | 566 ClassElementImpl(String name, int offset) : super(name, offset); |
| 561 | 567 |
| 562 /** | 568 /** |
| 563 * Initialize a newly created class element to have the given [name]. | 569 * Initialize a newly created class element to have the given [name]. |
| 564 */ | 570 */ |
| 565 ClassElementImpl.forNode(Identifier name) : super.forNode(name); | 571 ClassElementImpl.forNode(Identifier name) : super.forNode(name); |
| 566 | 572 |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 | 1153 |
| 1148 PropertyAccessorElement _internalLookUpConcreteGetter( | 1154 PropertyAccessorElement _internalLookUpConcreteGetter( |
| 1149 String getterName, LibraryElement library, bool includeThisClass) { | 1155 String getterName, LibraryElement library, bool includeThisClass) { |
| 1150 PropertyAccessorElement getter = | 1156 PropertyAccessorElement getter = |
| 1151 _internalLookUpGetter(getterName, library, includeThisClass); | 1157 _internalLookUpGetter(getterName, library, includeThisClass); |
| 1152 while (getter != null && getter.isAbstract) { | 1158 while (getter != null && getter.isAbstract) { |
| 1153 Element definingClass = getter.enclosingElement; | 1159 Element definingClass = getter.enclosingElement; |
| 1154 if (definingClass is! ClassElementImpl) { | 1160 if (definingClass is! ClassElementImpl) { |
| 1155 return null; | 1161 return null; |
| 1156 } | 1162 } |
| 1157 getter = (definingClass as ClassElementImpl)._internalLookUpGetter( | 1163 getter = (definingClass as ClassElementImpl) |
| 1158 getterName, library, false); | 1164 ._internalLookUpGetter(getterName, library, false); |
| 1159 } | 1165 } |
| 1160 return getter; | 1166 return getter; |
| 1161 } | 1167 } |
| 1162 | 1168 |
| 1163 MethodElement _internalLookUpConcreteMethod( | 1169 MethodElement _internalLookUpConcreteMethod( |
| 1164 String methodName, LibraryElement library, bool includeThisClass) { | 1170 String methodName, LibraryElement library, bool includeThisClass) { |
| 1165 MethodElement method = | 1171 MethodElement method = |
| 1166 _internalLookUpMethod(methodName, library, includeThisClass); | 1172 _internalLookUpMethod(methodName, library, includeThisClass); |
| 1167 while (method != null && method.isAbstract) { | 1173 while (method != null && method.isAbstract) { |
| 1168 ClassElement definingClass = method.enclosingElement; | 1174 ClassElement definingClass = method.enclosingElement; |
| 1169 if (definingClass == null) { | 1175 if (definingClass == null) { |
| 1170 return null; | 1176 return null; |
| 1171 } | 1177 } |
| 1172 method = definingClass.lookUpInheritedMethod(methodName, library); | 1178 method = definingClass.lookUpInheritedMethod(methodName, library); |
| 1173 } | 1179 } |
| 1174 return method; | 1180 return method; |
| 1175 } | 1181 } |
| 1176 | 1182 |
| 1177 PropertyAccessorElement _internalLookUpConcreteSetter( | 1183 PropertyAccessorElement _internalLookUpConcreteSetter( |
| 1178 String setterName, LibraryElement library, bool includeThisClass) { | 1184 String setterName, LibraryElement library, bool includeThisClass) { |
| 1179 PropertyAccessorElement setter = | 1185 PropertyAccessorElement setter = |
| 1180 _internalLookUpSetter(setterName, library, includeThisClass); | 1186 _internalLookUpSetter(setterName, library, includeThisClass); |
| 1181 while (setter != null && setter.isAbstract) { | 1187 while (setter != null && setter.isAbstract) { |
| 1182 Element definingClass = setter.enclosingElement; | 1188 Element definingClass = setter.enclosingElement; |
| 1183 if (definingClass is! ClassElementImpl) { | 1189 if (definingClass is! ClassElementImpl) { |
| 1184 return null; | 1190 return null; |
| 1185 } | 1191 } |
| 1186 setter = (definingClass as ClassElementImpl)._internalLookUpSetter( | 1192 setter = (definingClass as ClassElementImpl) |
| 1187 setterName, library, false); | 1193 ._internalLookUpSetter(setterName, library, false); |
| 1188 } | 1194 } |
| 1189 return setter; | 1195 return setter; |
| 1190 } | 1196 } |
| 1191 | 1197 |
| 1192 PropertyAccessorElement _internalLookUpGetter( | 1198 PropertyAccessorElement _internalLookUpGetter( |
| 1193 String getterName, LibraryElement library, bool includeThisClass) { | 1199 String getterName, LibraryElement library, bool includeThisClass) { |
| 1194 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 1200 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 1195 ClassElement currentElement = this; | 1201 ClassElement currentElement = this; |
| 1196 if (includeThisClass) { | 1202 if (includeThisClass) { |
| 1197 PropertyAccessorElement element = currentElement.getGetter(getterName); | 1203 PropertyAccessorElement element = currentElement.getGetter(getterName); |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 * Return the display name of this element, or `null` if this element does not | 2456 * Return the display name of this element, or `null` if this element does not |
| 2451 * have a name. | 2457 * have a name. |
| 2452 * | 2458 * |
| 2453 * In most cases the name and the display name are the same. Differences | 2459 * In most cases the name and the display name are the same. Differences |
| 2454 * though are cases such as setters where the name of some setter `set f(x)` | 2460 * though are cases such as setters where the name of some setter `set f(x)` |
| 2455 * is `f=`, instead of `f`. | 2461 * is `f=`, instead of `f`. |
| 2456 */ | 2462 */ |
| 2457 String get displayName; | 2463 String get displayName; |
| 2458 | 2464 |
| 2459 /** | 2465 /** |
| 2466 * Return the source range of the documentation comment for this element, |
| 2467 * or `null` if this element does not or cannot have a documentation. |
| 2468 */ |
| 2469 SourceRange get docRange; |
| 2470 |
| 2471 /** |
| 2460 * Return the element that either physically or logically encloses this | 2472 * Return the element that either physically or logically encloses this |
| 2461 * element. This will be `null` if this element is a library because libraries | 2473 * element. This will be `null` if this element is a library because libraries |
| 2462 * are the top-level elements in the model. | 2474 * are the top-level elements in the model. |
| 2463 */ | 2475 */ |
| 2464 Element get enclosingElement; | 2476 Element get enclosingElement; |
| 2465 | 2477 |
| 2466 /** | 2478 /** |
| 2467 * The unique integer identifier of this element. | 2479 * The unique integer identifier of this element. |
| 2468 */ | 2480 */ |
| 2469 int get id; | 2481 int get id; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 */ | 2536 */ |
| 2525 List<ElementAnnotation> get metadata; | 2537 List<ElementAnnotation> get metadata; |
| 2526 | 2538 |
| 2527 /** | 2539 /** |
| 2528 * Return the name of this element, or `null` if this element does not have a | 2540 * Return the name of this element, or `null` if this element does not have a |
| 2529 * name. | 2541 * name. |
| 2530 */ | 2542 */ |
| 2531 String get name; | 2543 String get name; |
| 2532 | 2544 |
| 2533 /** | 2545 /** |
| 2546 * Return the length of the name of this element in the file that contains the |
| 2547 * declaration of this element, or `0` if this element does not have a name. |
| 2548 */ |
| 2549 int get nameLength; |
| 2550 |
| 2551 /** |
| 2534 * Return the offset of the name of this element in the file that contains the | 2552 * Return the offset of the name of this element in the file that contains the |
| 2535 * declaration of this element, or `-1` if this element is synthetic, does not | 2553 * declaration of this element, or `-1` if this element is synthetic, does not |
| 2536 * have a name, or otherwise does not have an offset. | 2554 * have a name, or otherwise does not have an offset. |
| 2537 */ | 2555 */ |
| 2538 int get nameOffset; | 2556 int get nameOffset; |
| 2539 | 2557 |
| 2540 /** | 2558 /** |
| 2559 * **DEPRECATED** Use `computeNode()` instead. |
| 2560 * |
| 2541 * Return the resolved [AstNode] node that declares this element, or `null` if | 2561 * Return the resolved [AstNode] node that declares this element, or `null` if |
| 2542 * this element is synthetic or isn't contained in a compilation unit, such as | 2562 * this element is synthetic or isn't contained in a compilation unit, such as |
| 2543 * a [LibraryElement]. | 2563 * a [LibraryElement]. |
| 2544 * | 2564 * |
| 2545 * This method is expensive, because resolved AST might be evicted from cache, | 2565 * This method is expensive, because resolved AST might be evicted from cache, |
| 2546 * so parsing and resolving will be performed. | 2566 * so parsing and resolving will be performed. |
| 2547 * | 2567 * |
| 2548 * <b>Note:</b> This method cannot be used in an async environment. | 2568 * <b>Note:</b> This method cannot be used in an async environment. |
| 2549 */ | 2569 */ |
| 2550 @deprecated | 2570 @deprecated |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 * A cached copy of the calculated hashCode for this element. | 2828 * A cached copy of the calculated hashCode for this element. |
| 2809 */ | 2829 */ |
| 2810 int _cachedHashCode; | 2830 int _cachedHashCode; |
| 2811 | 2831 |
| 2812 /** | 2832 /** |
| 2813 * A cached copy of the calculated location for this element. | 2833 * A cached copy of the calculated location for this element. |
| 2814 */ | 2834 */ |
| 2815 ElementLocation _cachedLocation; | 2835 ElementLocation _cachedLocation; |
| 2816 | 2836 |
| 2817 /** | 2837 /** |
| 2838 * The offset to the beginning of the documentation comment, |
| 2839 * or `null` if this element does not have a documentation comment. |
| 2840 */ |
| 2841 int _docRangeOffset; |
| 2842 |
| 2843 /** |
| 2844 * The length of the documentation comment range for this element. |
| 2845 */ |
| 2846 int _docRangeLength; |
| 2847 |
| 2848 /** |
| 2818 * Initialize a newly created element to have the given [name] at the given | 2849 * Initialize a newly created element to have the given [name] at the given |
| 2819 * [_nameOffset]. | 2850 * [_nameOffset]. |
| 2820 */ | 2851 */ |
| 2821 ElementImpl(String name, this._nameOffset) { | 2852 ElementImpl(String name, this._nameOffset) { |
| 2822 this._name = StringUtilities.intern(name); | 2853 this._name = StringUtilities.intern(name); |
| 2823 } | 2854 } |
| 2824 | 2855 |
| 2825 /** | 2856 /** |
| 2826 * Initialize a newly created element to have the given [name]. | 2857 * Initialize a newly created element to have the given [name]. |
| 2827 */ | 2858 */ |
| 2828 ElementImpl.forNode(Identifier name) | 2859 ElementImpl.forNode(Identifier name) |
| 2829 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); | 2860 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); |
| 2830 | 2861 |
| 2831 @override | 2862 @override |
| 2832 AnalysisContext get context { | 2863 AnalysisContext get context { |
| 2833 if (_enclosingElement == null) { | 2864 if (_enclosingElement == null) { |
| 2834 return null; | 2865 return null; |
| 2835 } | 2866 } |
| 2836 return _enclosingElement.context; | 2867 return _enclosingElement.context; |
| 2837 } | 2868 } |
| 2838 | 2869 |
| 2839 @override | 2870 @override |
| 2840 String get displayName => _name; | 2871 String get displayName => _name; |
| 2841 | 2872 |
| 2842 @override | 2873 @override |
| 2874 SourceRange get docRange { |
| 2875 if (_docRangeOffset != null && _docRangeLength != null) { |
| 2876 return new SourceRange(_docRangeOffset, _docRangeLength); |
| 2877 } |
| 2878 return null; |
| 2879 } |
| 2880 |
| 2881 @override |
| 2843 Element get enclosingElement => _enclosingElement; | 2882 Element get enclosingElement => _enclosingElement; |
| 2844 | 2883 |
| 2845 /** | 2884 /** |
| 2846 * Set the enclosing element of this element to the given [element]. | 2885 * Set the enclosing element of this element to the given [element]. |
| 2847 */ | 2886 */ |
| 2848 void set enclosingElement(Element element) { | 2887 void set enclosingElement(Element element) { |
| 2849 _enclosingElement = element as ElementImpl; | 2888 _enclosingElement = element as ElementImpl; |
| 2850 _cachedLocation = null; | 2889 _cachedLocation = null; |
| 2851 _cachedHashCode = null; | 2890 _cachedHashCode = null; |
| 2852 } | 2891 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2922 | 2961 |
| 2923 @override | 2962 @override |
| 2924 String get name => _name; | 2963 String get name => _name; |
| 2925 | 2964 |
| 2926 void set name(String name) { | 2965 void set name(String name) { |
| 2927 this._name = name; | 2966 this._name = name; |
| 2928 _cachedLocation = null; | 2967 _cachedLocation = null; |
| 2929 _cachedHashCode = null; | 2968 _cachedHashCode = null; |
| 2930 } | 2969 } |
| 2931 | 2970 |
| 2932 /** | 2971 @override |
| 2933 * The offset of the name of this element in the file that contains the | 2972 int get nameLength => displayName != null ? displayName.length : 0; |
| 2934 * declaration of this element. | 2973 |
| 2935 */ | 2974 @override |
| 2936 int get nameOffset => _nameOffset; | 2975 int get nameOffset => _nameOffset; |
| 2937 | 2976 |
| 2938 /** | 2977 /** |
| 2939 * Sets the offset of the name of this element in the file that contains the | 2978 * Sets the offset of the name of this element in the file that contains the |
| 2940 * declaration of this element. | 2979 * declaration of this element. |
| 2941 */ | 2980 */ |
| 2942 void set nameOffset(int offset) { | 2981 void set nameOffset(int offset) { |
| 2943 _nameOffset = offset; | 2982 _nameOffset = offset; |
| 2944 _cachedHashCode = null; | 2983 _cachedHashCode = null; |
| 2945 _cachedLocation = null; | 2984 _cachedLocation = null; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 */ | 3121 */ |
| 3083 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { | 3122 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { |
| 3084 if (children != null) { | 3123 if (children != null) { |
| 3085 for (Element child in children) { | 3124 for (Element child in children) { |
| 3086 child.accept(visitor); | 3125 child.accept(visitor); |
| 3087 } | 3126 } |
| 3088 } | 3127 } |
| 3089 } | 3128 } |
| 3090 | 3129 |
| 3091 /** | 3130 /** |
| 3131 * Set the documentation comment source range for this element. |
| 3132 */ |
| 3133 void setDocRange(int offset, int length) { |
| 3134 _docRangeOffset = offset; |
| 3135 _docRangeLength = length; |
| 3136 } |
| 3137 |
| 3138 /** |
| 3092 * Set whether the given [modifier] is associated with this element to | 3139 * Set whether the given [modifier] is associated with this element to |
| 3093 * correspond to the given [value]. | 3140 * correspond to the given [value]. |
| 3094 */ | 3141 */ |
| 3095 void setModifier(Modifier modifier, bool value) { | 3142 void setModifier(Modifier modifier, bool value) { |
| 3096 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); | 3143 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); |
| 3097 } | 3144 } |
| 3098 | 3145 |
| 3099 @override | 3146 @override |
| 3100 String toString() { | 3147 String toString() { |
| 3101 StringBuffer buffer = new StringBuffer(); | 3148 StringBuffer buffer = new StringBuffer(); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3515 */ | 3562 */ |
| 3516 static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; | 3563 static const List<ExecutableElement> EMPTY_LIST = const <ExecutableElement>[]; |
| 3517 | 3564 |
| 3518 /** | 3565 /** |
| 3519 * Return a list containing all of the functions defined within this | 3566 * Return a list containing all of the functions defined within this |
| 3520 * executable element. | 3567 * executable element. |
| 3521 */ | 3568 */ |
| 3522 List<FunctionElement> get functions; | 3569 List<FunctionElement> get functions; |
| 3523 | 3570 |
| 3524 /** | 3571 /** |
| 3572 * Return `true` if this executable element did not have an explicit return |
| 3573 * type specified for it in the original source. Note that if there was no |
| 3574 * explicit return type, and if the element model is fully populated, then |
| 3575 * the [returnType] will not be `null`. |
| 3576 */ |
| 3577 bool get hasImplicitReturnType; |
| 3578 |
| 3579 /** |
| 3525 * Return `true` if this executable element is abstract. Executable elements | 3580 * Return `true` if this executable element is abstract. Executable elements |
| 3526 * are abstract if they are not external and have no body. | 3581 * are abstract if they are not external and have no body. |
| 3527 */ | 3582 */ |
| 3528 bool get isAbstract; | 3583 bool get isAbstract; |
| 3529 | 3584 |
| 3530 /** | 3585 /** |
| 3531 * Return `true` if this executable element has body marked as being | 3586 * Return `true` if this executable element has body marked as being |
| 3532 * asynchronous. | 3587 * asynchronous. |
| 3533 */ | 3588 */ |
| 3534 bool get isAsynchronous; | 3589 bool get isAsynchronous; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3578 */ | 3633 */ |
| 3579 List<LocalVariableElement> get localVariables; | 3634 List<LocalVariableElement> get localVariables; |
| 3580 | 3635 |
| 3581 /** | 3636 /** |
| 3582 * Return a list containing all of the parameters defined by this executable | 3637 * Return a list containing all of the parameters defined by this executable |
| 3583 * element. | 3638 * element. |
| 3584 */ | 3639 */ |
| 3585 List<ParameterElement> get parameters; | 3640 List<ParameterElement> get parameters; |
| 3586 | 3641 |
| 3587 /** | 3642 /** |
| 3588 * Return the return type defined by this executable element. | 3643 * Return the return type defined by this executable element. If the element |
| 3644 * model is fully populated, then the [returnType] will not be `null`, even |
| 3645 * if no return type was explicitly specified. |
| 3589 */ | 3646 */ |
| 3590 DartType get returnType; | 3647 DartType get returnType; |
| 3591 | 3648 |
| 3592 /** | 3649 /** |
| 3593 * Return the type of function defined by this executable element. | 3650 * Return the type of function defined by this executable element. |
| 3594 */ | 3651 */ |
| 3595 FunctionType get type; | 3652 FunctionType get type; |
| 3596 | 3653 |
| 3597 /** | 3654 /** |
| 3598 * Return a list containing all of the type parameters defined for this | 3655 * Return a list containing all of the type parameters defined for this |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3691 } | 3748 } |
| 3692 | 3749 |
| 3693 /** | 3750 /** |
| 3694 * Set whether this method's body is a generator. | 3751 * Set whether this method's body is a generator. |
| 3695 */ | 3752 */ |
| 3696 void set generator(bool isGenerator) { | 3753 void set generator(bool isGenerator) { |
| 3697 setModifier(Modifier.GENERATOR, isGenerator); | 3754 setModifier(Modifier.GENERATOR, isGenerator); |
| 3698 } | 3755 } |
| 3699 | 3756 |
| 3700 @override | 3757 @override |
| 3758 bool get hasImplicitReturnType => hasModifier(Modifier.IMPLICIT_TYPE); |
| 3759 |
| 3760 /** |
| 3761 * Set whether this executable element has an implicit return type. |
| 3762 */ |
| 3763 void set hasImplicitReturnType(bool hasImplicitReturnType) { |
| 3764 setModifier(Modifier.IMPLICIT_TYPE, hasImplicitReturnType); |
| 3765 } |
| 3766 |
| 3767 @override |
| 3701 bool get isAbstract => hasModifier(Modifier.ABSTRACT); | 3768 bool get isAbstract => hasModifier(Modifier.ABSTRACT); |
| 3702 | 3769 |
| 3703 @override | 3770 @override |
| 3704 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); | 3771 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); |
| 3705 | 3772 |
| 3706 @override | 3773 @override |
| 3707 bool get isExternal => hasModifier(Modifier.EXTERNAL); | 3774 bool get isExternal => hasModifier(Modifier.EXTERNAL); |
| 3708 | 3775 |
| 3709 @override | 3776 @override |
| 3710 bool get isGenerator => hasModifier(Modifier.GENERATOR); | 3777 bool get isGenerator => hasModifier(Modifier.GENERATOR); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3877 List<FunctionElement> get functions { | 3944 List<FunctionElement> get functions { |
| 3878 // | 3945 // |
| 3879 // Elements within this element should have type parameters substituted, | 3946 // Elements within this element should have type parameters substituted, |
| 3880 // just like this element. | 3947 // just like this element. |
| 3881 // | 3948 // |
| 3882 throw new UnsupportedOperationException(); | 3949 throw new UnsupportedOperationException(); |
| 3883 // return getBaseElement().getFunctions(); | 3950 // return getBaseElement().getFunctions(); |
| 3884 } | 3951 } |
| 3885 | 3952 |
| 3886 @override | 3953 @override |
| 3954 bool get hasImplicitReturnType => baseElement.hasImplicitReturnType; |
| 3955 |
| 3956 @override |
| 3887 bool get isAbstract => baseElement.isAbstract; | 3957 bool get isAbstract => baseElement.isAbstract; |
| 3888 | 3958 |
| 3889 @override | 3959 @override |
| 3890 bool get isAsynchronous => baseElement.isAsynchronous; | 3960 bool get isAsynchronous => baseElement.isAsynchronous; |
| 3891 | 3961 |
| 3892 @override | 3962 @override |
| 3893 bool get isExternal => baseElement.isExternal; | 3963 bool get isExternal => baseElement.isExternal; |
| 3894 | 3964 |
| 3895 @override | 3965 @override |
| 3896 bool get isGenerator => baseElement.isGenerator; | 3966 bool get isGenerator => baseElement.isGenerator; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4080 * so parsing and resolving will be performed. | 4150 * so parsing and resolving will be performed. |
| 4081 */ | 4151 */ |
| 4082 @override | 4152 @override |
| 4083 AstNode computeNode(); | 4153 AstNode computeNode(); |
| 4084 } | 4154 } |
| 4085 | 4155 |
| 4086 /** | 4156 /** |
| 4087 * A concrete implementation of a [FieldElement]. | 4157 * A concrete implementation of a [FieldElement]. |
| 4088 */ | 4158 */ |
| 4089 class FieldElementImpl extends PropertyInducingElementImpl | 4159 class FieldElementImpl extends PropertyInducingElementImpl |
| 4090 with PotentiallyConstVariableElement implements FieldElement { | 4160 with PotentiallyConstVariableElement |
| 4161 implements FieldElement { |
| 4091 /** | 4162 /** |
| 4092 * An empty list of field elements. | 4163 * An empty list of field elements. |
| 4093 */ | 4164 */ |
| 4094 @deprecated // Use FieldElement.EMPTY_LIST | 4165 @deprecated // Use FieldElement.EMPTY_LIST |
| 4095 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; | 4166 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; |
| 4096 | 4167 |
| 4097 /** | 4168 /** |
| 4098 * Initialize a newly created synthetic field element to have the given [name] | 4169 * Initialize a newly created synthetic field element to have the given [name] |
| 4099 * at the given [offset]. | 4170 * at the given [offset]. |
| 4100 */ | 4171 */ |
| 4101 FieldElementImpl(String name, int offset) : super(name, offset); | 4172 FieldElementImpl(String name, int offset) : super(name, offset); |
| 4102 | 4173 |
| 4103 /** | 4174 /** |
| 4104 * Initialize a newly created field element to have the given [name]. | 4175 * Initialize a newly created field element to have the given [name]. |
| 4105 */ | 4176 */ |
| 4106 FieldElementImpl.forNode(Identifier name) : super.forNode(name); | 4177 FieldElementImpl.forNode(Identifier name) : super.forNode(name); |
| 4107 | 4178 |
| 4108 @override | 4179 @override |
| 4109 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | 4180 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
| 4110 | 4181 |
| 4111 @override | 4182 @override |
| 4112 bool get isEnumConstant => | 4183 bool get isEnumConstant => |
| 4113 enclosingElement != null ? enclosingElement.isEnum : false; | 4184 enclosingElement != null ? enclosingElement.isEnum : false; |
| 4114 | 4185 |
| 4115 @override | 4186 @override |
| 4116 bool get isStatic => hasModifier(Modifier.STATIC); | |
| 4117 | |
| 4118 @override | |
| 4119 ElementKind get kind => ElementKind.FIELD; | 4187 ElementKind get kind => ElementKind.FIELD; |
| 4120 | 4188 |
| 4121 /** | 4189 /** |
| 4122 * Set whether this field is static. | 4190 * Set whether this field is static. |
| 4123 */ | 4191 */ |
| 4124 void set static(bool isStatic) { | 4192 void set static(bool isStatic) { |
| 4125 setModifier(Modifier.STATIC, isStatic); | 4193 setModifier(Modifier.STATIC, isStatic); |
| 4126 } | 4194 } |
| 4127 | 4195 |
| 4128 @override | 4196 @override |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4223 ClassElement get enclosingElement => baseElement.enclosingElement; | 4291 ClassElement get enclosingElement => baseElement.enclosingElement; |
| 4224 | 4292 |
| 4225 @override | 4293 @override |
| 4226 PropertyAccessorElement get getter => | 4294 PropertyAccessorElement get getter => |
| 4227 PropertyAccessorMember.from(baseElement.getter, definingType); | 4295 PropertyAccessorMember.from(baseElement.getter, definingType); |
| 4228 | 4296 |
| 4229 @override | 4297 @override |
| 4230 bool get isEnumConstant => baseElement.isEnumConstant; | 4298 bool get isEnumConstant => baseElement.isEnumConstant; |
| 4231 | 4299 |
| 4232 @override | 4300 @override |
| 4233 bool get isStatic => baseElement.isStatic; | |
| 4234 | |
| 4235 @override | |
| 4236 DartType get propagatedType => substituteFor(baseElement.propagatedType); | 4301 DartType get propagatedType => substituteFor(baseElement.propagatedType); |
| 4237 | 4302 |
| 4238 @override | 4303 @override |
| 4239 PropertyAccessorElement get setter => | 4304 PropertyAccessorElement get setter => |
| 4240 PropertyAccessorMember.from(baseElement.setter, definingType); | 4305 PropertyAccessorMember.from(baseElement.setter, definingType); |
| 4241 | 4306 |
| 4242 @override | 4307 @override |
| 4243 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 4308 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); |
| 4244 | 4309 |
| 4245 @override | 4310 @override |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4954 if (parameters.length == 0) { | 5019 if (parameters.length == 0) { |
| 4955 return namedParameterTypes; | 5020 return namedParameterTypes; |
| 4956 } | 5021 } |
| 4957 List<DartType> typeParameters = | 5022 List<DartType> typeParameters = |
| 4958 TypeParameterTypeImpl.getTypes(this.typeParameters); | 5023 TypeParameterTypeImpl.getTypes(this.typeParameters); |
| 4959 for (ParameterElement parameter in parameters) { | 5024 for (ParameterElement parameter in parameters) { |
| 4960 if (parameter.parameterKind == ParameterKind.NAMED) { | 5025 if (parameter.parameterKind == ParameterKind.NAMED) { |
| 4961 DartType type = parameter.type; | 5026 DartType type = parameter.type; |
| 4962 if (typeArguments.length != 0 && | 5027 if (typeArguments.length != 0 && |
| 4963 typeArguments.length == typeParameters.length) { | 5028 typeArguments.length == typeParameters.length) { |
| 4964 type = (type as TypeImpl).substitute2( | 5029 type = (type as TypeImpl) |
| 4965 typeArguments, typeParameters, newPrune); | 5030 .substitute2(typeArguments, typeParameters, newPrune); |
| 4966 } else { | 5031 } else { |
| 4967 type = (type as TypeImpl).pruned(newPrune); | 5032 type = (type as TypeImpl).pruned(newPrune); |
| 4968 } | 5033 } |
| 4969 namedParameterTypes[parameter.name] = type; | 5034 namedParameterTypes[parameter.name] = type; |
| 4970 } | 5035 } |
| 4971 } | 5036 } |
| 4972 return namedParameterTypes; | 5037 return namedParameterTypes; |
| 4973 } | 5038 } |
| 4974 | 5039 |
| 4975 /** | 5040 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5000 return DartType.EMPTY_LIST; | 5065 return DartType.EMPTY_LIST; |
| 5001 } | 5066 } |
| 5002 List<DartType> typeParameters = | 5067 List<DartType> typeParameters = |
| 5003 TypeParameterTypeImpl.getTypes(this.typeParameters); | 5068 TypeParameterTypeImpl.getTypes(this.typeParameters); |
| 5004 List<DartType> types = new List<DartType>(); | 5069 List<DartType> types = new List<DartType>(); |
| 5005 for (ParameterElement parameter in parameters) { | 5070 for (ParameterElement parameter in parameters) { |
| 5006 if (parameter.parameterKind == ParameterKind.REQUIRED) { | 5071 if (parameter.parameterKind == ParameterKind.REQUIRED) { |
| 5007 DartType type = parameter.type; | 5072 DartType type = parameter.type; |
| 5008 if (typeArguments.length != 0 && | 5073 if (typeArguments.length != 0 && |
| 5009 typeArguments.length == typeParameters.length) { | 5074 typeArguments.length == typeParameters.length) { |
| 5010 type = (type as TypeImpl).substitute2( | 5075 type = (type as TypeImpl) |
| 5011 typeArguments, typeParameters, newPrune); | 5076 .substitute2(typeArguments, typeParameters, newPrune); |
| 5012 } else { | 5077 } else { |
| 5013 type = (type as TypeImpl).pruned(newPrune); | 5078 type = (type as TypeImpl).pruned(newPrune); |
| 5014 } | 5079 } |
| 5015 types.add(type); | 5080 types.add(type); |
| 5016 } | 5081 } |
| 5017 } | 5082 } |
| 5018 return types; | 5083 return types; |
| 5019 } | 5084 } |
| 5020 | 5085 |
| 5021 @override | 5086 @override |
| 5022 List<DartType> get optionalParameterTypes { | 5087 List<DartType> get optionalParameterTypes { |
| 5023 List<ParameterElement> parameters = baseParameters; | 5088 List<ParameterElement> parameters = baseParameters; |
| 5024 if (parameters.length == 0) { | 5089 if (parameters.length == 0) { |
| 5025 return DartType.EMPTY_LIST; | 5090 return DartType.EMPTY_LIST; |
| 5026 } | 5091 } |
| 5027 List<DartType> typeParameters = | 5092 List<DartType> typeParameters = |
| 5028 TypeParameterTypeImpl.getTypes(this.typeParameters); | 5093 TypeParameterTypeImpl.getTypes(this.typeParameters); |
| 5029 List<DartType> types = new List<DartType>(); | 5094 List<DartType> types = new List<DartType>(); |
| 5030 for (ParameterElement parameter in parameters) { | 5095 for (ParameterElement parameter in parameters) { |
| 5031 if (parameter.parameterKind == ParameterKind.POSITIONAL) { | 5096 if (parameter.parameterKind == ParameterKind.POSITIONAL) { |
| 5032 DartType type = parameter.type; | 5097 DartType type = parameter.type; |
| 5033 if (typeArguments.length != 0 && | 5098 if (typeArguments.length != 0 && |
| 5034 typeArguments.length == typeParameters.length) { | 5099 typeArguments.length == typeParameters.length) { |
| 5035 type = (type as TypeImpl).substitute2( | 5100 type = (type as TypeImpl) |
| 5036 typeArguments, typeParameters, newPrune); | 5101 .substitute2(typeArguments, typeParameters, newPrune); |
| 5037 } else { | 5102 } else { |
| 5038 type = (type as TypeImpl).pruned(newPrune); | 5103 type = (type as TypeImpl).pruned(newPrune); |
| 5039 } | 5104 } |
| 5040 types.add(type); | 5105 types.add(type); |
| 5041 } | 5106 } |
| 5042 } | 5107 } |
| 5043 return types; | 5108 return types; |
| 5044 } | 5109 } |
| 5045 | 5110 |
| 5046 @override | 5111 @override |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5208 return false; | 5273 return false; |
| 5209 } | 5274 } |
| 5210 // named parameters case | 5275 // named parameters case |
| 5211 if (t.namedParameterTypes.length > 0) { | 5276 if (t.namedParameterTypes.length > 0) { |
| 5212 // check that the number of required parameters are equal, and check that | 5277 // check that the number of required parameters are equal, and check that |
| 5213 // every t_i is more specific than every s_i | 5278 // every t_i is more specific than every s_i |
| 5214 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | 5279 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 5215 return false; | 5280 return false; |
| 5216 } else if (t.normalParameterTypes.length > 0) { | 5281 } else if (t.normalParameterTypes.length > 0) { |
| 5217 for (int i = 0; i < tTypes.length; i++) { | 5282 for (int i = 0; i < tTypes.length; i++) { |
| 5218 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( | 5283 if (!(tTypes[i] as TypeImpl) |
| 5219 sTypes[i], withDynamic)) { | 5284 .isMoreSpecificThan(sTypes[i], withDynamic)) { |
| 5220 return false; | 5285 return false; |
| 5221 } | 5286 } |
| 5222 } | 5287 } |
| 5223 } | 5288 } |
| 5224 Map<String, DartType> namedTypesT = t.namedParameterTypes; | 5289 Map<String, DartType> namedTypesT = t.namedParameterTypes; |
| 5225 Map<String, DartType> namedTypesS = s.namedParameterTypes; | 5290 Map<String, DartType> namedTypesS = s.namedParameterTypes; |
| 5226 // if k >= m is false, return false: the passed function type has more | 5291 // if k >= m is false, return false: the passed function type has more |
| 5227 // named parameter types than this | 5292 // named parameter types than this |
| 5228 if (namedTypesT.length < namedTypesS.length) { | 5293 if (namedTypesT.length < namedTypesS.length) { |
| 5229 return false; | 5294 return false; |
| 5230 } | 5295 } |
| 5231 // Loop through each element in S verifying that T has a matching | 5296 // Loop through each element in S verifying that T has a matching |
| 5232 // parameter name and that the corresponding type is more specific then | 5297 // parameter name and that the corresponding type is more specific then |
| 5233 // the type in S. | 5298 // the type in S. |
| 5234 for (String keyS in namedTypesS.keys) { | 5299 for (String keyS in namedTypesS.keys) { |
| 5235 DartType typeT = namedTypesT[keyS]; | 5300 DartType typeT = namedTypesT[keyS]; |
| 5236 if (typeT == null) { | 5301 if (typeT == null) { |
| 5237 return false; | 5302 return false; |
| 5238 } | 5303 } |
| 5239 if (!(typeT as TypeImpl).isMoreSpecificThan( | 5304 if (!(typeT as TypeImpl) |
| 5240 namedTypesS[keyS], withDynamic)) { | 5305 .isMoreSpecificThan(namedTypesS[keyS], withDynamic)) { |
| 5241 return false; | 5306 return false; |
| 5242 } | 5307 } |
| 5243 } | 5308 } |
| 5244 } else if (s.namedParameterTypes.length > 0) { | 5309 } else if (s.namedParameterTypes.length > 0) { |
| 5245 return false; | 5310 return false; |
| 5246 } else { | 5311 } else { |
| 5247 // positional parameter case | 5312 // positional parameter case |
| 5248 int tArgLength = tTypes.length + tOpTypes.length; | 5313 int tArgLength = tTypes.length + tOpTypes.length; |
| 5249 int sArgLength = sTypes.length + sOpTypes.length; | 5314 int sArgLength = sTypes.length + sOpTypes.length; |
| 5250 // Check that the total number of parameters in t is greater than or equal | 5315 // Check that the total number of parameters in t is greater than or equal |
| 5251 // to the number of parameters in s and that the number of required | 5316 // to the number of parameters in s and that the number of required |
| 5252 // parameters in s is greater than or equal to the number of required | 5317 // parameters in s is greater than or equal to the number of required |
| 5253 // parameters in t. | 5318 // parameters in t. |
| 5254 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | 5319 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 5255 return false; | 5320 return false; |
| 5256 } | 5321 } |
| 5257 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | 5322 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 5258 // No positional arguments, don't copy contents to new array | 5323 // No positional arguments, don't copy contents to new array |
| 5259 for (int i = 0; i < sTypes.length; i++) { | 5324 for (int i = 0; i < sTypes.length; i++) { |
| 5260 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( | 5325 if (!(tTypes[i] as TypeImpl) |
| 5261 sTypes[i], withDynamic)) { | 5326 .isMoreSpecificThan(sTypes[i], withDynamic)) { |
| 5262 return false; | 5327 return false; |
| 5263 } | 5328 } |
| 5264 } | 5329 } |
| 5265 } else { | 5330 } else { |
| 5266 // Else, we do have positional parameters, copy required and positional | 5331 // Else, we do have positional parameters, copy required and positional |
| 5267 // parameter types into arrays to do the compare (for loop below). | 5332 // parameter types into arrays to do the compare (for loop below). |
| 5268 List<DartType> tAllTypes = new List<DartType>(sArgLength); | 5333 List<DartType> tAllTypes = new List<DartType>(sArgLength); |
| 5269 for (int i = 0; i < tTypes.length; i++) { | 5334 for (int i = 0; i < tTypes.length; i++) { |
| 5270 tAllTypes[i] = tTypes[i]; | 5335 tAllTypes[i] = tTypes[i]; |
| 5271 } | 5336 } |
| 5272 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { | 5337 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5273 tAllTypes[i] = tOpTypes[j]; | 5338 tAllTypes[i] = tOpTypes[j]; |
| 5274 } | 5339 } |
| 5275 List<DartType> sAllTypes = new List<DartType>(sArgLength); | 5340 List<DartType> sAllTypes = new List<DartType>(sArgLength); |
| 5276 for (int i = 0; i < sTypes.length; i++) { | 5341 for (int i = 0; i < sTypes.length; i++) { |
| 5277 sAllTypes[i] = sTypes[i]; | 5342 sAllTypes[i] = sTypes[i]; |
| 5278 } | 5343 } |
| 5279 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { | 5344 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5280 sAllTypes[i] = sOpTypes[j]; | 5345 sAllTypes[i] = sOpTypes[j]; |
| 5281 } | 5346 } |
| 5282 for (int i = 0; i < sAllTypes.length; i++) { | 5347 for (int i = 0; i < sAllTypes.length; i++) { |
| 5283 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan( | 5348 if (!(tAllTypes[i] as TypeImpl) |
| 5284 sAllTypes[i], withDynamic)) { | 5349 .isMoreSpecificThan(sAllTypes[i], withDynamic)) { |
| 5285 return false; | 5350 return false; |
| 5286 } | 5351 } |
| 5287 } | 5352 } |
| 5288 } | 5353 } |
| 5289 } | 5354 } |
| 5290 DartType tRetType = t.returnType; | 5355 DartType tRetType = t.returnType; |
| 5291 DartType sRetType = s.returnType; | 5356 DartType sRetType = s.returnType; |
| 5292 return sRetType.isVoid || | 5357 return sRetType.isVoid || |
| 5293 (tRetType as TypeImpl).isMoreSpecificThan(sRetType, withDynamic); | 5358 (tRetType as TypeImpl).isMoreSpecificThan(sRetType, withDynamic); |
| 5294 } | 5359 } |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6626 // | 6691 // |
| 6627 ClassElement tElement = this.element; | 6692 ClassElement tElement = this.element; |
| 6628 ClassElement sElement = type.element; | 6693 ClassElement sElement = type.element; |
| 6629 if (tElement == sElement) { | 6694 if (tElement == sElement) { |
| 6630 List<DartType> tArguments = typeArguments; | 6695 List<DartType> tArguments = typeArguments; |
| 6631 List<DartType> sArguments = type.typeArguments; | 6696 List<DartType> sArguments = type.typeArguments; |
| 6632 if (tArguments.length != sArguments.length) { | 6697 if (tArguments.length != sArguments.length) { |
| 6633 return false; | 6698 return false; |
| 6634 } | 6699 } |
| 6635 for (int i = 0; i < tArguments.length; i++) { | 6700 for (int i = 0; i < tArguments.length; i++) { |
| 6636 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan( | 6701 if (!(tArguments[i] as TypeImpl) |
| 6637 sArguments[i], withDynamic)) { | 6702 .isMoreSpecificThan(sArguments[i], withDynamic)) { |
| 6638 return false; | 6703 return false; |
| 6639 } | 6704 } |
| 6640 } | 6705 } |
| 6641 return true; | 6706 return true; |
| 6642 } | 6707 } |
| 6643 } | 6708 } |
| 6644 // | 6709 // |
| 6645 // Transitivity: T << U and U << S. | 6710 // Transitivity: T << U and U << S. |
| 6646 // | 6711 // |
| 6647 // First check for infinite loops | 6712 // First check for infinite loops |
| 6648 if (element == null) { | 6713 if (element == null) { |
| 6649 return false; | 6714 return false; |
| 6650 } | 6715 } |
| 6651 if (visitedElements == null) { | 6716 if (visitedElements == null) { |
| 6652 visitedElements = new HashSet<ClassElement>(); | 6717 visitedElements = new HashSet<ClassElement>(); |
| 6653 } else if (visitedElements.contains(element)) { | 6718 } else if (visitedElements.contains(element)) { |
| 6654 return false; | 6719 return false; |
| 6655 } | 6720 } |
| 6656 visitedElements.add(element); | 6721 visitedElements.add(element); |
| 6657 try { | 6722 try { |
| 6658 // Iterate over all of the types U that are more specific than T because | 6723 // Iterate over all of the types U that are more specific than T because |
| 6659 // they are direct supertypes of T and return true if any of them are more | 6724 // they are direct supertypes of T and return true if any of them are more |
| 6660 // specific than S. | 6725 // specific than S. |
| 6661 InterfaceTypeImpl supertype = superclass; | 6726 InterfaceTypeImpl supertype = superclass; |
| 6662 if (supertype != null && | 6727 if (supertype != null && |
| 6663 supertype.isMoreSpecificThan(type, withDynamic, visitedElements)) { | 6728 supertype.isMoreSpecificThan(type, withDynamic, visitedElements)) { |
| 6664 return true; | 6729 return true; |
| 6665 } | 6730 } |
| 6666 for (InterfaceType interfaceType in interfaces) { | 6731 for (InterfaceType interfaceType in interfaces) { |
| 6667 if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan( | 6732 if ((interfaceType as InterfaceTypeImpl) |
| 6668 type, withDynamic, visitedElements)) { | 6733 .isMoreSpecificThan(type, withDynamic, visitedElements)) { |
| 6669 return true; | 6734 return true; |
| 6670 } | 6735 } |
| 6671 } | 6736 } |
| 6672 for (InterfaceType mixinType in mixins) { | 6737 for (InterfaceType mixinType in mixins) { |
| 6673 if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan( | 6738 if ((mixinType as InterfaceTypeImpl) |
| 6674 type, withDynamic, visitedElements)) { | 6739 .isMoreSpecificThan(type, withDynamic, visitedElements)) { |
| 6675 return true; | 6740 return true; |
| 6676 } | 6741 } |
| 6677 } | 6742 } |
| 6678 // If a type I includes an instance method named `call`, and the type of | 6743 // If a type I includes an instance method named `call`, and the type of |
| 6679 // `call` is the function type F, then I is considered to be more specific | 6744 // `call` is the function type F, then I is considered to be more specific |
| 6680 // than F. | 6745 // than F. |
| 6681 MethodElement callMethod = getMethod('call'); | 6746 MethodElement callMethod = getMethod('call'); |
| 6682 if (callMethod != null && !callMethod.isStatic) { | 6747 if (callMethod != null && !callMethod.isStatic) { |
| 6683 FunctionTypeImpl callType = callMethod.type; | 6748 FunctionTypeImpl callType = callMethod.type; |
| 6684 if (callType.isMoreSpecificThan(type, withDynamic, visitedElements)) { | 6749 if (callType.isMoreSpecificThan(type, withDynamic, visitedElements)) { |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7269 */ | 7334 */ |
| 7270 List<ImportElement> _imports = ImportElement.EMPTY_LIST; | 7335 List<ImportElement> _imports = ImportElement.EMPTY_LIST; |
| 7271 | 7336 |
| 7272 /** | 7337 /** |
| 7273 * A list containing specifications of all of the exports defined in this | 7338 * A list containing specifications of all of the exports defined in this |
| 7274 * library. | 7339 * library. |
| 7275 */ | 7340 */ |
| 7276 List<ExportElement> _exports = ExportElement.EMPTY_LIST; | 7341 List<ExportElement> _exports = ExportElement.EMPTY_LIST; |
| 7277 | 7342 |
| 7278 /** | 7343 /** |
| 7344 * A list containing the strongly connected component in the import/export |
| 7345 * graph in which the current library resides. Computed on demand, null |
| 7346 * if not present. If _libraryCycle is set, then the _libraryCycle field |
| 7347 * for all libraries reachable from this library in the import/export graph |
| 7348 * is also set. |
| 7349 */ |
| 7350 List<LibraryElement> _libraryCycle = null; |
| 7351 |
| 7352 /** |
| 7279 * A list containing all of the compilation units that are included in this | 7353 * A list containing all of the compilation units that are included in this |
| 7280 * library using a `part` directive. | 7354 * library using a `part` directive. |
| 7281 */ | 7355 */ |
| 7282 List<CompilationUnitElement> _parts = CompilationUnitElement.EMPTY_LIST; | 7356 List<CompilationUnitElement> _parts = CompilationUnitElement.EMPTY_LIST; |
| 7283 | 7357 |
| 7284 /** | 7358 /** |
| 7285 * The element representing the synthetic function `loadLibrary` that is | 7359 * The element representing the synthetic function `loadLibrary` that is |
| 7286 * defined for this library, or `null` if the element has not yet been created
. | 7360 * defined for this library, or `null` if the element has not yet been created
. |
| 7287 */ | 7361 */ |
| 7288 FunctionElement _loadLibraryFunction; | 7362 FunctionElement _loadLibraryFunction; |
| 7289 | 7363 |
| 7364 @override |
| 7365 final int nameLength; |
| 7366 |
| 7290 /** | 7367 /** |
| 7291 * The export [Namespace] of this library, `null` if it has not been | 7368 * The export [Namespace] of this library, `null` if it has not been |
| 7292 * computed yet. | 7369 * computed yet. |
| 7293 */ | 7370 */ |
| 7294 @override | 7371 @override |
| 7295 Namespace exportNamespace; | 7372 Namespace exportNamespace; |
| 7296 | 7373 |
| 7297 /** | 7374 /** |
| 7298 * The public [Namespace] of this library, `null` if it has not been | 7375 * The public [Namespace] of this library, `null` if it has not been |
| 7299 * computed yet. | 7376 * computed yet. |
| 7300 */ | 7377 */ |
| 7301 @override | 7378 @override |
| 7302 Namespace publicNamespace; | 7379 Namespace publicNamespace; |
| 7303 | 7380 |
| 7304 /** | 7381 /** |
| 7305 * Initialize a newly created library element in the given [context] to have | 7382 * Initialize a newly created library element in the given [context] to have |
| 7306 * the given [name] and [offset]. | 7383 * the given [name] and [offset]. |
| 7307 */ | 7384 */ |
| 7308 LibraryElementImpl(this.context, String name, int offset) | 7385 LibraryElementImpl(this.context, String name, int offset, this.nameLength) |
| 7309 : super(name, offset); | 7386 : super(name, offset); |
| 7310 | 7387 |
| 7311 /** | 7388 /** |
| 7312 * Initialize a newly created library element in the given [context] to have | 7389 * Initialize a newly created library element in the given [context] to have |
| 7313 * the given [name]. | 7390 * the given [name]. |
| 7314 */ | 7391 */ |
| 7315 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 7392 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
| 7316 : super.forNode(name); | 7393 : super.forNode(name), |
| 7394 nameLength = name != null ? name.length : 0; |
| 7317 | 7395 |
| 7318 @override | 7396 @override |
| 7319 CompilationUnitElement get definingCompilationUnit => | 7397 CompilationUnitElement get definingCompilationUnit => |
| 7320 _definingCompilationUnit; | 7398 _definingCompilationUnit; |
| 7321 | 7399 |
| 7322 /** | 7400 /** |
| 7323 * Set the compilation unit that defines this library to the given compilation | 7401 * Set the compilation unit that defines this library to the given compilation |
| 7324 * [unit]. | 7402 * [unit]. |
| 7325 */ | 7403 */ |
| 7326 void set definingCompilationUnit(CompilationUnitElement unit) { | 7404 void set definingCompilationUnit(CompilationUnitElement unit) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7452 } | 7530 } |
| 7453 return false; | 7531 return false; |
| 7454 } | 7532 } |
| 7455 | 7533 |
| 7456 @override | 7534 @override |
| 7457 ElementKind get kind => ElementKind.LIBRARY; | 7535 ElementKind get kind => ElementKind.LIBRARY; |
| 7458 | 7536 |
| 7459 @override | 7537 @override |
| 7460 LibraryElement get library => this; | 7538 LibraryElement get library => this; |
| 7461 | 7539 |
| 7540 List<LibraryElement> get libraryCycle { |
| 7541 if (_libraryCycle != null) { |
| 7542 return _libraryCycle; |
| 7543 } |
| 7544 |
| 7545 // Global counter for this run of the algorithm |
| 7546 int counter = 0; |
| 7547 // The discovery times of each library |
| 7548 Map<LibraryElementImpl, int> indices = {}; |
| 7549 // The set of scc candidates |
| 7550 Set<LibraryElementImpl> active = new Set(); |
| 7551 // The stack of discovered elements |
| 7552 List<LibraryElementImpl> stack = []; |
| 7553 // For a given library that has not yet been processed by this run of the |
| 7554 // algorithm, compute the strongly connected components. |
| 7555 int scc(LibraryElementImpl library) { |
| 7556 int index = counter++; |
| 7557 int root = index; |
| 7558 indices[library] = index; |
| 7559 active.add(library); |
| 7560 stack.add(library); |
| 7561 void recurse(LibraryElementImpl child) { |
| 7562 if (!indices.containsKey(child)) { |
| 7563 // We haven't visited this child yet, so recurse on the child, |
| 7564 // returning the lowest numbered node reachable from the child. If |
| 7565 // the child can reach a root which is lower numbered than anything |
| 7566 // we've reached so far, update the root. |
| 7567 root = min(root, scc(child)); |
| 7568 } else if (active.contains(child)) { |
| 7569 // The child has been visited, but has not yet been placed into a |
| 7570 // component. If the child is higher than anything we've seen so far |
| 7571 // update the root appropriately. |
| 7572 root = min(root, indices[child]); |
| 7573 } |
| 7574 } |
| 7575 // Recurse on all of the children in the import/export graph, filtering |
| 7576 // out those for which library cycles have already been computed. |
| 7577 library.exportedLibraries |
| 7578 .where((l) => l._libraryCycle == null) |
| 7579 .forEach(recurse); |
| 7580 library.importedLibraries |
| 7581 .where((l) => l._libraryCycle == null) |
| 7582 .forEach(recurse); |
| 7583 |
| 7584 if (root == index) { |
| 7585 // This is the root of a strongly connected component. |
| 7586 // Pop the elements, and share the component across all |
| 7587 // of the elements. |
| 7588 List<LibraryElement> component = <LibraryElement>[]; |
| 7589 LibraryElementImpl cur = null; |
| 7590 do { |
| 7591 cur = stack.removeLast(); |
| 7592 active.remove(cur); |
| 7593 component.add(cur); |
| 7594 cur._libraryCycle = component; |
| 7595 } while (cur != library); |
| 7596 } |
| 7597 return root; |
| 7598 } |
| 7599 scc(library); |
| 7600 return _libraryCycle; |
| 7601 } |
| 7602 |
| 7462 @override | 7603 @override |
| 7463 FunctionElement get loadLibraryFunction { | 7604 FunctionElement get loadLibraryFunction { |
| 7464 if (_loadLibraryFunction == null) { | 7605 if (_loadLibraryFunction == null) { |
| 7465 FunctionElementImpl function = | 7606 FunctionElementImpl function = |
| 7466 new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1); | 7607 new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1); |
| 7467 function.synthetic = true; | 7608 function.synthetic = true; |
| 7468 function.enclosingElement = this; | 7609 function.enclosingElement = this; |
| 7469 function.returnType = loadLibraryReturnType; | 7610 function.returnType = loadLibraryReturnType; |
| 7470 function.type = new FunctionTypeImpl(function); | 7611 function.type = new FunctionTypeImpl(function); |
| 7471 _loadLibraryFunction = function; | 7612 _loadLibraryFunction = function; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7638 void _addVisibleLibraries( | 7779 void _addVisibleLibraries( |
| 7639 Set<LibraryElement> visibleLibraries, bool includeExports) { | 7780 Set<LibraryElement> visibleLibraries, bool includeExports) { |
| 7640 // maybe already processed | 7781 // maybe already processed |
| 7641 if (!visibleLibraries.add(this)) { | 7782 if (!visibleLibraries.add(this)) { |
| 7642 return; | 7783 return; |
| 7643 } | 7784 } |
| 7644 // add imported libraries | 7785 // add imported libraries |
| 7645 for (ImportElement importElement in _imports) { | 7786 for (ImportElement importElement in _imports) { |
| 7646 LibraryElement importedLibrary = importElement.importedLibrary; | 7787 LibraryElement importedLibrary = importElement.importedLibrary; |
| 7647 if (importedLibrary != null) { | 7788 if (importedLibrary != null) { |
| 7648 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7789 (importedLibrary as LibraryElementImpl) |
| 7649 visibleLibraries, true); | 7790 ._addVisibleLibraries(visibleLibraries, true); |
| 7650 } | 7791 } |
| 7651 } | 7792 } |
| 7652 // add exported libraries | 7793 // add exported libraries |
| 7653 if (includeExports) { | 7794 if (includeExports) { |
| 7654 for (ExportElement exportElement in _exports) { | 7795 for (ExportElement exportElement in _exports) { |
| 7655 LibraryElement exportedLibrary = exportElement.exportedLibrary; | 7796 LibraryElement exportedLibrary = exportElement.exportedLibrary; |
| 7656 if (exportedLibrary != null) { | 7797 if (exportedLibrary != null) { |
| 7657 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7798 (exportedLibrary as LibraryElementImpl) |
| 7658 visibleLibraries, true); | 7799 ._addVisibleLibraries(visibleLibraries, true); |
| 7659 } | 7800 } |
| 7660 } | 7801 } |
| 7661 } | 7802 } |
| 7662 } | 7803 } |
| 7663 | 7804 |
| 7664 /** | 7805 /** |
| 7665 * Return `true` if the given [library] is up to date with respect to the | 7806 * Return `true` if the given [library] is up to date with respect to the |
| 7666 * given [timeStamp]. The set of [visitedLibraries] is used to prevent | 7807 * given [timeStamp]. The set of [visitedLibraries] is used to prevent |
| 7667 * infinite recusion in the case of mutually dependent libraries. | 7808 * infinite recusion in the case of mutually dependent libraries. |
| 7668 */ | 7809 */ |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7742 * so parsing and resolving will be performed. | 7883 * so parsing and resolving will be performed. |
| 7743 */ | 7884 */ |
| 7744 @override | 7885 @override |
| 7745 VariableDeclaration computeNode(); | 7886 VariableDeclaration computeNode(); |
| 7746 } | 7887 } |
| 7747 | 7888 |
| 7748 /** | 7889 /** |
| 7749 * A concrete implementation of a [LocalVariableElement]. | 7890 * A concrete implementation of a [LocalVariableElement]. |
| 7750 */ | 7891 */ |
| 7751 class LocalVariableElementImpl extends VariableElementImpl | 7892 class LocalVariableElementImpl extends VariableElementImpl |
| 7752 with PotentiallyConstVariableElement implements LocalVariableElement { | 7893 with PotentiallyConstVariableElement |
| 7894 implements LocalVariableElement { |
| 7753 /** | 7895 /** |
| 7754 * An empty list of field elements. | 7896 * An empty list of field elements. |
| 7755 */ | 7897 */ |
| 7756 @deprecated // Use LocalVariableElement.EMPTY_LIST | 7898 @deprecated // Use LocalVariableElement.EMPTY_LIST |
| 7757 static const List<LocalVariableElement> EMPTY_ARRAY = | 7899 static const List<LocalVariableElement> EMPTY_ARRAY = |
| 7758 const <LocalVariableElement>[]; | 7900 const <LocalVariableElement>[]; |
| 7759 | 7901 |
| 7760 /** | 7902 /** |
| 7761 * The offset to the beginning of the visible range for this element. | 7903 * The offset to the beginning of the visible range for this element. |
| 7762 */ | 7904 */ |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7874 AnalysisContext get context => _baseElement.context; | 8016 AnalysisContext get context => _baseElement.context; |
| 7875 | 8017 |
| 7876 /** | 8018 /** |
| 7877 * Return the type in which the element is defined. | 8019 * Return the type in which the element is defined. |
| 7878 */ | 8020 */ |
| 7879 ParameterizedType get definingType => _definingType; | 8021 ParameterizedType get definingType => _definingType; |
| 7880 | 8022 |
| 7881 @override | 8023 @override |
| 7882 String get displayName => _baseElement.displayName; | 8024 String get displayName => _baseElement.displayName; |
| 7883 | 8025 |
| 8026 @override |
| 8027 SourceRange get docRange => _baseElement.docRange; |
| 8028 |
| 7884 int get id => _baseElement.id; | 8029 int get id => _baseElement.id; |
| 7885 | 8030 |
| 7886 @override | 8031 @override |
| 7887 bool get isDeprecated => _baseElement.isDeprecated; | 8032 bool get isDeprecated => _baseElement.isDeprecated; |
| 7888 | 8033 |
| 7889 @override | 8034 @override |
| 7890 bool get isOverride => _baseElement.isOverride; | 8035 bool get isOverride => _baseElement.isOverride; |
| 7891 | 8036 |
| 7892 @override | 8037 @override |
| 7893 bool get isPrivate => _baseElement.isPrivate; | 8038 bool get isPrivate => _baseElement.isPrivate; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7907 @override | 8052 @override |
| 7908 ElementLocation get location => _baseElement.location; | 8053 ElementLocation get location => _baseElement.location; |
| 7909 | 8054 |
| 7910 @override | 8055 @override |
| 7911 List<ElementAnnotation> get metadata => _baseElement.metadata; | 8056 List<ElementAnnotation> get metadata => _baseElement.metadata; |
| 7912 | 8057 |
| 7913 @override | 8058 @override |
| 7914 String get name => _baseElement.name; | 8059 String get name => _baseElement.name; |
| 7915 | 8060 |
| 7916 @override | 8061 @override |
| 8062 int get nameLength => _baseElement.nameLength; |
| 8063 |
| 8064 @override |
| 7917 int get nameOffset => _baseElement.nameOffset; | 8065 int get nameOffset => _baseElement.nameOffset; |
| 7918 | 8066 |
| 7919 @deprecated | 8067 @deprecated |
| 7920 @override | 8068 @override |
| 7921 AstNode get node => computeNode(); | 8069 AstNode get node => computeNode(); |
| 7922 | 8070 |
| 7923 @override | 8071 @override |
| 7924 Source get source => _baseElement.source; | 8072 Source get source => _baseElement.source; |
| 7925 | 8073 |
| 7926 @override | 8074 @override |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8244 static const Modifier GETTER = const Modifier('GETTER', 9); | 8392 static const Modifier GETTER = const Modifier('GETTER', 9); |
| 8245 | 8393 |
| 8246 /** | 8394 /** |
| 8247 * A flag used for libraries indicating that the defining compilation unit | 8395 * A flag used for libraries indicating that the defining compilation unit |
| 8248 * contains at least one import directive whose URI uses the "dart-ext" | 8396 * contains at least one import directive whose URI uses the "dart-ext" |
| 8249 * scheme. | 8397 * scheme. |
| 8250 */ | 8398 */ |
| 8251 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); | 8399 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); |
| 8252 | 8400 |
| 8253 /** | 8401 /** |
| 8402 * Indicates that the associated element did not have an explicit type |
| 8403 * associated with it. If the element is an [ExecutableElement], then the |
| 8404 * type being referred to is the return type. |
| 8405 */ |
| 8406 static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); |
| 8407 |
| 8408 /** |
| 8254 * Indicates that a class can validly be used as a mixin. | 8409 * Indicates that a class can validly be used as a mixin. |
| 8255 */ | 8410 */ |
| 8256 static const Modifier MIXIN = const Modifier('MIXIN', 11); | 8411 static const Modifier MIXIN = const Modifier('MIXIN', 12); |
| 8257 | 8412 |
| 8258 /** | 8413 /** |
| 8259 * Indicates that a class is a mixin application. | 8414 * Indicates that a class is a mixin application. |
| 8260 */ | 8415 */ |
| 8261 static const Modifier MIXIN_APPLICATION = | 8416 static const Modifier MIXIN_APPLICATION = |
| 8262 const Modifier('MIXIN_APPLICATION', 12); | 8417 const Modifier('MIXIN_APPLICATION', 13); |
| 8263 | 8418 |
| 8264 /** | 8419 /** |
| 8265 * Indicates that the value of a parameter or local variable might be mutated | 8420 * Indicates that the value of a parameter or local variable might be mutated |
| 8266 * within the context. | 8421 * within the context. |
| 8267 */ | 8422 */ |
| 8268 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = | 8423 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
| 8269 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13); | 8424 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 14); |
| 8270 | 8425 |
| 8271 /** | 8426 /** |
| 8272 * Indicates that the value of a parameter or local variable might be mutated | 8427 * Indicates that the value of a parameter or local variable might be mutated |
| 8273 * within the scope. | 8428 * within the scope. |
| 8274 */ | 8429 */ |
| 8275 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = | 8430 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
| 8276 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14); | 8431 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 15); |
| 8277 | 8432 |
| 8278 /** | 8433 /** |
| 8279 * Indicates that a class contains an explicit reference to 'super'. | 8434 * Indicates that a class contains an explicit reference to 'super'. |
| 8280 */ | 8435 */ |
| 8281 static const Modifier REFERENCES_SUPER = | 8436 static const Modifier REFERENCES_SUPER = |
| 8282 const Modifier('REFERENCES_SUPER', 15); | 8437 const Modifier('REFERENCES_SUPER', 16); |
| 8283 | 8438 |
| 8284 /** | 8439 /** |
| 8285 * Indicates that the pseudo-modifier 'set' was applied to the element. | 8440 * Indicates that the pseudo-modifier 'set' was applied to the element. |
| 8286 */ | 8441 */ |
| 8287 static const Modifier SETTER = const Modifier('SETTER', 16); | 8442 static const Modifier SETTER = const Modifier('SETTER', 17); |
| 8288 | 8443 |
| 8289 /** | 8444 /** |
| 8290 * Indicates that the modifier 'static' was applied to the element. | 8445 * Indicates that the modifier 'static' was applied to the element. |
| 8291 */ | 8446 */ |
| 8292 static const Modifier STATIC = const Modifier('STATIC', 17); | 8447 static const Modifier STATIC = const Modifier('STATIC', 18); |
| 8293 | 8448 |
| 8294 /** | 8449 /** |
| 8295 * Indicates that the element does not appear in the source code but was | 8450 * Indicates that the element does not appear in the source code but was |
| 8296 * implicitly created. For example, if a class does not define any | 8451 * implicitly created. For example, if a class does not define any |
| 8297 * constructors, an implicit zero-argument constructor will be created and it | 8452 * constructors, an implicit zero-argument constructor will be created and it |
| 8298 * will be marked as being synthetic. | 8453 * will be marked as being synthetic. |
| 8299 */ | 8454 */ |
| 8300 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18); | 8455 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 19); |
| 8301 | 8456 |
| 8302 static const List<Modifier> values = const [ | 8457 static const List<Modifier> values = const [ |
| 8303 ABSTRACT, | 8458 ABSTRACT, |
| 8304 ASYNCHRONOUS, | 8459 ASYNCHRONOUS, |
| 8305 CONST, | 8460 CONST, |
| 8306 DEFERRED, | 8461 DEFERRED, |
| 8307 ENUM, | 8462 ENUM, |
| 8308 EXTERNAL, | 8463 EXTERNAL, |
| 8309 FACTORY, | 8464 FACTORY, |
| 8310 FINAL, | 8465 FINAL, |
| 8311 GENERATOR, | 8466 GENERATOR, |
| 8312 GETTER, | 8467 GETTER, |
| 8313 HAS_EXT_URI, | 8468 HAS_EXT_URI, |
| 8469 IMPLICIT_TYPE, |
| 8314 MIXIN, | 8470 MIXIN, |
| 8315 MIXIN_APPLICATION, | 8471 MIXIN_APPLICATION, |
| 8316 POTENTIALLY_MUTATED_IN_CONTEXT, | 8472 POTENTIALLY_MUTATED_IN_CONTEXT, |
| 8317 POTENTIALLY_MUTATED_IN_SCOPE, | 8473 POTENTIALLY_MUTATED_IN_SCOPE, |
| 8318 REFERENCES_SUPER, | 8474 REFERENCES_SUPER, |
| 8319 SETTER, | 8475 SETTER, |
| 8320 STATIC, | 8476 STATIC, |
| 8321 SYNTHETIC | 8477 SYNTHETIC |
| 8322 ]; | 8478 ]; |
| 8323 | 8479 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8373 * list of [conflictingElements]. | 8529 * list of [conflictingElements]. |
| 8374 */ | 8530 */ |
| 8375 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { | 8531 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { |
| 8376 _name = conflictingElements[0].name; | 8532 _name = conflictingElements[0].name; |
| 8377 } | 8533 } |
| 8378 | 8534 |
| 8379 @override | 8535 @override |
| 8380 String get displayName => _name; | 8536 String get displayName => _name; |
| 8381 | 8537 |
| 8382 @override | 8538 @override |
| 8539 SourceRange get docRange => null; |
| 8540 |
| 8541 @override |
| 8383 Element get enclosingElement => null; | 8542 Element get enclosingElement => null; |
| 8384 | 8543 |
| 8385 @override | 8544 @override |
| 8386 bool get isDeprecated => false; | 8545 bool get isDeprecated => false; |
| 8387 | 8546 |
| 8388 @override | 8547 @override |
| 8389 bool get isOverride => false; | 8548 bool get isOverride => false; |
| 8390 | 8549 |
| 8391 @override | 8550 @override |
| 8392 bool get isPrivate { | 8551 bool get isPrivate { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8412 @override | 8571 @override |
| 8413 ElementLocation get location => null; | 8572 ElementLocation get location => null; |
| 8414 | 8573 |
| 8415 @override | 8574 @override |
| 8416 List<ElementAnnotation> get metadata => ElementAnnotation.EMPTY_LIST; | 8575 List<ElementAnnotation> get metadata => ElementAnnotation.EMPTY_LIST; |
| 8417 | 8576 |
| 8418 @override | 8577 @override |
| 8419 String get name => _name; | 8578 String get name => _name; |
| 8420 | 8579 |
| 8421 @override | 8580 @override |
| 8581 int get nameLength => displayName != null ? displayName.length : 0; |
| 8582 |
| 8583 @override |
| 8422 int get nameOffset => -1; | 8584 int get nameOffset => -1; |
| 8423 | 8585 |
| 8424 @deprecated | 8586 @deprecated |
| 8425 @override | 8587 @override |
| 8426 AstNode get node => null; | 8588 AstNode get node => null; |
| 8427 | 8589 |
| 8428 @override | 8590 @override |
| 8429 Source get source => null; | 8591 Source get source => null; |
| 8430 | 8592 |
| 8431 @override | 8593 @override |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8644 */ | 8806 */ |
| 8645 List<ParameterElement> get parameters; | 8807 List<ParameterElement> get parameters; |
| 8646 | 8808 |
| 8647 /** | 8809 /** |
| 8648 * Return a list containing all of the type parameters defined by this | 8810 * Return a list containing all of the type parameters defined by this |
| 8649 * parameter. A parameter will only define other parameters if it is a | 8811 * parameter. A parameter will only define other parameters if it is a |
| 8650 * function typed parameter. | 8812 * function typed parameter. |
| 8651 */ | 8813 */ |
| 8652 List<TypeParameterElement> get typeParameters; | 8814 List<TypeParameterElement> get typeParameters; |
| 8653 | 8815 |
| 8816 /** |
| 8817 * Append the type, name and possibly the default value of this parameter to |
| 8818 * the given [buffer]. |
| 8819 */ |
| 8820 void appendToWithoutDelimiters(StringBuffer buffer); |
| 8821 |
| 8654 @override | 8822 @override |
| 8655 FormalParameter computeNode(); | 8823 FormalParameter computeNode(); |
| 8656 } | 8824 } |
| 8657 | 8825 |
| 8658 /** | 8826 /** |
| 8659 * A concrete implementation of a [ParameterElement]. | 8827 * A concrete implementation of a [ParameterElement]. |
| 8660 */ | 8828 */ |
| 8661 class ParameterElementImpl extends VariableElementImpl | 8829 class ParameterElementImpl extends VariableElementImpl |
| 8662 with PotentiallyConstVariableElement implements ParameterElement { | 8830 with ParameterElementMixin, PotentiallyConstVariableElement |
| 8831 implements ParameterElement { |
| 8663 /** | 8832 /** |
| 8664 * An empty list of parameter elements. | 8833 * An empty list of parameter elements. |
| 8665 */ | 8834 */ |
| 8666 @deprecated // Use ParameterElement.EMPTY_LIST | 8835 @deprecated // Use ParameterElement.EMPTY_LIST |
| 8667 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; | 8836 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; |
| 8668 | 8837 |
| 8669 /** | 8838 /** |
| 8670 * A list containing all of the parameters defined by this parameter element. | 8839 * A list containing all of the parameters defined by this parameter element. |
| 8671 * There will only be parameters if this parameter is a function typed | 8840 * There will only be parameters if this parameter is a function typed |
| 8672 * parameter. | 8841 * parameter. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8787 left = "["; | 8956 left = "["; |
| 8788 right = "]"; | 8957 right = "]"; |
| 8789 } else if (parameterKind == ParameterKind.REQUIRED) {} | 8958 } else if (parameterKind == ParameterKind.REQUIRED) {} |
| 8790 break; | 8959 break; |
| 8791 } | 8960 } |
| 8792 buffer.write(left); | 8961 buffer.write(left); |
| 8793 appendToWithoutDelimiters(buffer); | 8962 appendToWithoutDelimiters(buffer); |
| 8794 buffer.write(right); | 8963 buffer.write(right); |
| 8795 } | 8964 } |
| 8796 | 8965 |
| 8797 /** | |
| 8798 * Append the type and name of this parameter to the given [buffer]. | |
| 8799 */ | |
| 8800 void appendToWithoutDelimiters(StringBuffer buffer) { | |
| 8801 buffer.write(type); | |
| 8802 buffer.write(" "); | |
| 8803 buffer.write(displayName); | |
| 8804 if (_defaultValueCode != null) { | |
| 8805 if (parameterKind == ParameterKind.NAMED) { | |
| 8806 buffer.write(": "); | |
| 8807 } | |
| 8808 if (parameterKind == ParameterKind.POSITIONAL) { | |
| 8809 buffer.write(" = "); | |
| 8810 } | |
| 8811 buffer.write(_defaultValueCode); | |
| 8812 } | |
| 8813 } | |
| 8814 | |
| 8815 @override | 8966 @override |
| 8816 FormalParameter computeNode() => | 8967 FormalParameter computeNode() => |
| 8817 getNodeMatching((node) => node is FormalParameter); | 8968 getNodeMatching((node) => node is FormalParameter); |
| 8818 | 8969 |
| 8819 @override | 8970 @override |
| 8820 ElementImpl getChild(String identifier) { | 8971 ElementImpl getChild(String identifier) { |
| 8821 for (ParameterElement parameter in _parameters) { | 8972 for (ParameterElement parameter in _parameters) { |
| 8822 if ((parameter as ParameterElementImpl).identifier == identifier) { | 8973 if ((parameter as ParameterElementImpl).identifier == identifier) { |
| 8823 return parameter as ParameterElementImpl; | 8974 return parameter as ParameterElementImpl; |
| 8824 } | 8975 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 8850 } | 9001 } |
| 8851 | 9002 |
| 8852 @override | 9003 @override |
| 8853 void visitChildren(ElementVisitor visitor) { | 9004 void visitChildren(ElementVisitor visitor) { |
| 8854 super.visitChildren(visitor); | 9005 super.visitChildren(visitor); |
| 8855 safelyVisitChildren(_parameters, visitor); | 9006 safelyVisitChildren(_parameters, visitor); |
| 8856 } | 9007 } |
| 8857 } | 9008 } |
| 8858 | 9009 |
| 8859 /** | 9010 /** |
| 9011 * A mixin that provides a common implementation for methods defined in |
| 9012 * [ParameterElement]. |
| 9013 */ |
| 9014 abstract class ParameterElementMixin implements ParameterElement { |
| 9015 @override |
| 9016 void appendToWithoutDelimiters(StringBuffer buffer) { |
| 9017 buffer.write(type); |
| 9018 buffer.write(" "); |
| 9019 buffer.write(displayName); |
| 9020 if (defaultValueCode != null) { |
| 9021 if (parameterKind == ParameterKind.NAMED) { |
| 9022 buffer.write(": "); |
| 9023 } |
| 9024 if (parameterKind == ParameterKind.POSITIONAL) { |
| 9025 buffer.write(" = "); |
| 9026 } |
| 9027 buffer.write(defaultValueCode); |
| 9028 } |
| 9029 } |
| 9030 } |
| 9031 |
| 9032 /** |
| 8860 * A type with type parameters, such as a class or function type alias. | 9033 * A type with type parameters, such as a class or function type alias. |
| 8861 */ | 9034 */ |
| 8862 abstract class ParameterizedType implements DartType { | 9035 abstract class ParameterizedType implements DartType { |
| 8863 /** | 9036 /** |
| 8864 * Return a list containing the actual types of the type arguments. If this | 9037 * Return a list containing the actual types of the type arguments. If this |
| 8865 * type's element does not have type parameters, then the array should be | 9038 * type's element does not have type parameters, then the array should be |
| 8866 * empty (although it is possible for type arguments to be erroneously | 9039 * empty (although it is possible for type arguments to be erroneously |
| 8867 * declared). If the element has type parameters and the actual type does not | 9040 * declared). If the element has type parameters and the actual type does not |
| 8868 * explicitly include argument values, then the type "dynamic" will be | 9041 * explicitly include argument values, then the type "dynamic" will be |
| 8869 * automatically provided. | 9042 * automatically provided. |
| 8870 */ | 9043 */ |
| 8871 List<DartType> get typeArguments; | 9044 List<DartType> get typeArguments; |
| 8872 | 9045 |
| 8873 /** | 9046 /** |
| 8874 * Return a list containing all of the type parameters declared for this type. | 9047 * Return a list containing all of the type parameters declared for this type. |
| 8875 */ | 9048 */ |
| 8876 List<TypeParameterElement> get typeParameters; | 9049 List<TypeParameterElement> get typeParameters; |
| 8877 } | 9050 } |
| 8878 | 9051 |
| 8879 /** | 9052 /** |
| 8880 * A parameter element defined in a parameterized type where the values of the | 9053 * A parameter element defined in a parameterized type where the values of the |
| 8881 * type parameters are known. | 9054 * type parameters are known. |
| 8882 */ | 9055 */ |
| 8883 class ParameterMember extends VariableMember implements ParameterElement { | 9056 class ParameterMember extends VariableMember |
| 9057 with ParameterElementMixin |
| 9058 implements ParameterElement { |
| 8884 /** | 9059 /** |
| 8885 * Initialize a newly created element to represent a constructor, based on the | 9060 * Initialize a newly created element to represent a constructor, based on the |
| 8886 * [baseElement], defined by the [definingType]. | 9061 * [baseElement], defined by the [definingType]. |
| 8887 */ | 9062 */ |
| 8888 ParameterMember(ParameterElement baseElement, ParameterizedType definingType) | 9063 ParameterMember(ParameterElement baseElement, ParameterizedType definingType) |
| 8889 : super(baseElement, definingType); | 9064 : super(baseElement, definingType); |
| 8890 | 9065 |
| 8891 @override | 9066 @override |
| 8892 ParameterElement get baseElement => super.baseElement as ParameterElement; | 9067 ParameterElement get baseElement => super.baseElement as ParameterElement; |
| 8893 | 9068 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9472 const <PropertyInducingElement>[]; | 9647 const <PropertyInducingElement>[]; |
| 9473 | 9648 |
| 9474 /** | 9649 /** |
| 9475 * Return the getter associated with this variable. If this variable was | 9650 * Return the getter associated with this variable. If this variable was |
| 9476 * explicitly defined (is not synthetic) then the getter associated with it | 9651 * explicitly defined (is not synthetic) then the getter associated with it |
| 9477 * will be synthetic. | 9652 * will be synthetic. |
| 9478 */ | 9653 */ |
| 9479 PropertyAccessorElement get getter; | 9654 PropertyAccessorElement get getter; |
| 9480 | 9655 |
| 9481 /** | 9656 /** |
| 9482 * Return `true` if this element is a static element. A static element is an | |
| 9483 * element that is not associated with a particular instance, but rather with | |
| 9484 * an entire library or class. | |
| 9485 */ | |
| 9486 bool get isStatic; | |
| 9487 | |
| 9488 /** | |
| 9489 * Return the propagated type of this variable, or `null` if type propagation | 9657 * Return the propagated type of this variable, or `null` if type propagation |
| 9490 * has not been performed, for example because the variable is not final. | 9658 * has not been performed, for example because the variable is not final. |
| 9491 */ | 9659 */ |
| 9492 DartType get propagatedType; | 9660 DartType get propagatedType; |
| 9493 | 9661 |
| 9494 /** | 9662 /** |
| 9495 * Return the setter associated with this variable, or `null` if the variable | 9663 * Return the setter associated with this variable, or `null` if the variable |
| 9496 * is effectively `final` and therefore does not have a setter associated with | 9664 * is effectively `final` and therefore does not have a setter associated with |
| 9497 * it. (This can happen either because the variable is explicitly defined as | 9665 * it. (This can happen either because the variable is explicitly defined as |
| 9498 * being `final` or because the variable is induced by an explicit getter that | 9666 * being `final` or because the variable is induced by an explicit getter that |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9841 const <TopLevelVariableElement>[]; | 10009 const <TopLevelVariableElement>[]; |
| 9842 | 10010 |
| 9843 @override | 10011 @override |
| 9844 VariableDeclaration computeNode(); | 10012 VariableDeclaration computeNode(); |
| 9845 } | 10013 } |
| 9846 | 10014 |
| 9847 /** | 10015 /** |
| 9848 * A concrete implementation of a [TopLevelVariableElement]. | 10016 * A concrete implementation of a [TopLevelVariableElement]. |
| 9849 */ | 10017 */ |
| 9850 class TopLevelVariableElementImpl extends PropertyInducingElementImpl | 10018 class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
| 9851 with PotentiallyConstVariableElement implements TopLevelVariableElement { | 10019 with PotentiallyConstVariableElement |
| 10020 implements TopLevelVariableElement { |
| 9852 /** | 10021 /** |
| 9853 * An empty list of top-level variable elements. | 10022 * An empty list of top-level variable elements. |
| 9854 */ | 10023 */ |
| 9855 @deprecated // Use TopLevelVariableElement.EMPTY_LIST | 10024 @deprecated // Use TopLevelVariableElement.EMPTY_LIST |
| 9856 static const List<TopLevelVariableElement> EMPTY_ARRAY = | 10025 static const List<TopLevelVariableElement> EMPTY_ARRAY = |
| 9857 const <TopLevelVariableElement>[]; | 10026 const <TopLevelVariableElement>[]; |
| 9858 | 10027 |
| 9859 /** | 10028 /** |
| 9860 * Initialize a newly created synthetic top-level variable element to have the | 10029 * Initialize a newly created synthetic top-level variable element to have the |
| 9861 * given [name] and [offset]. | 10030 * given [name] and [offset]. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10084 */ | 10253 */ |
| 10085 static List<DartType> substitute(List<DartType> types, | 10254 static List<DartType> substitute(List<DartType> types, |
| 10086 List<DartType> argumentTypes, List<DartType> parameterTypes, | 10255 List<DartType> argumentTypes, List<DartType> parameterTypes, |
| 10087 [List<FunctionTypeAliasElement> prune]) { | 10256 [List<FunctionTypeAliasElement> prune]) { |
| 10088 int length = types.length; | 10257 int length = types.length; |
| 10089 if (length == 0) { | 10258 if (length == 0) { |
| 10090 return types; | 10259 return types; |
| 10091 } | 10260 } |
| 10092 List<DartType> newTypes = new List<DartType>(length); | 10261 List<DartType> newTypes = new List<DartType>(length); |
| 10093 for (int i = 0; i < length; i++) { | 10262 for (int i = 0; i < length; i++) { |
| 10094 newTypes[i] = (types[i] as TypeImpl).substitute2( | 10263 newTypes[i] = (types[i] as TypeImpl) |
| 10095 argumentTypes, parameterTypes, prune); | 10264 .substitute2(argumentTypes, parameterTypes, prune); |
| 10096 } | 10265 } |
| 10097 return newTypes; | 10266 return newTypes; |
| 10098 } | 10267 } |
| 10099 } | 10268 } |
| 10100 | 10269 |
| 10101 /** | 10270 /** |
| 10102 * A type parameter. | 10271 * A type parameter. |
| 10103 */ | 10272 */ |
| 10104 abstract class TypeParameterElement implements Element { | 10273 abstract class TypeParameterElement implements TypeDefiningElement { |
| 10105 /** | 10274 /** |
| 10106 * An empty list of type parameter elements. | 10275 * An empty list of type parameter elements. |
| 10107 */ | 10276 */ |
| 10108 static const List<TypeParameterElement> EMPTY_LIST = | 10277 static const List<TypeParameterElement> EMPTY_LIST = |
| 10109 const <TypeParameterElement>[]; | 10278 const <TypeParameterElement>[]; |
| 10110 | 10279 |
| 10111 /** | 10280 /** |
| 10112 * Return the type representing the bound associated with this parameter, or | 10281 * Return the type representing the bound associated with this parameter, or |
| 10113 * `null` if this parameter does not have an explicit bound. | 10282 * `null` if this parameter does not have an explicit bound. |
| 10114 */ | 10283 */ |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10434 /** | 10603 /** |
| 10435 * A variable. There are concrete subclasses for different kinds of variables. | 10604 * A variable. There are concrete subclasses for different kinds of variables. |
| 10436 */ | 10605 */ |
| 10437 abstract class VariableElement implements Element, ConstantEvaluationTarget { | 10606 abstract class VariableElement implements Element, ConstantEvaluationTarget { |
| 10438 /** | 10607 /** |
| 10439 * An empty list of variable elements. | 10608 * An empty list of variable elements. |
| 10440 */ | 10609 */ |
| 10441 static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; | 10610 static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; |
| 10442 | 10611 |
| 10443 /** | 10612 /** |
| 10613 * Return `true` if this variable element did not have an explicit type |
| 10614 * specified for it. |
| 10615 */ |
| 10616 bool get hasImplicitType; |
| 10617 |
| 10618 /** |
| 10444 * Return a synthetic function representing this variable's initializer, or | 10619 * Return a synthetic function representing this variable's initializer, or |
| 10445 * `null` if this variable does not have an initializer. The function will | 10620 * `null` if this variable does not have an initializer. The function will |
| 10446 * have no parameters. The return type of the function will be the | 10621 * have no parameters. The return type of the function will be the |
| 10447 * compile-time type of the initialization expression. | 10622 * compile-time type of the initialization expression. |
| 10448 */ | 10623 */ |
| 10449 FunctionElement get initializer; | 10624 FunctionElement get initializer; |
| 10450 | 10625 |
| 10451 /** | 10626 /** |
| 10452 * Return `true` if this variable was declared with the 'const' modifier. | 10627 * Return `true` if this variable was declared with the 'const' modifier. |
| 10453 */ | 10628 */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10470 | 10645 |
| 10471 /** | 10646 /** |
| 10472 * Return `true` if this variable is potentially mutated somewhere in its | 10647 * Return `true` if this variable is potentially mutated somewhere in its |
| 10473 * scope. This information is only available for local variables (including | 10648 * scope. This information is only available for local variables (including |
| 10474 * parameters) and only after the compilation unit containing the variable has | 10649 * parameters) and only after the compilation unit containing the variable has |
| 10475 * been resolved. | 10650 * been resolved. |
| 10476 */ | 10651 */ |
| 10477 bool get isPotentiallyMutatedInScope; | 10652 bool get isPotentiallyMutatedInScope; |
| 10478 | 10653 |
| 10479 /** | 10654 /** |
| 10655 * Return `true` if this element is a static variable, as per section 8 of the |
| 10656 * Dart Language Specification: |
| 10657 * |
| 10658 * > A static variable is a variable that is not associated with a particular |
| 10659 * > instance, but rather with an entire library or class. Static variables |
| 10660 * > include library variables and class variables. Class variables are |
| 10661 * > variables whose declaration is immediately nested inside a class |
| 10662 * > declaration and includes the modifier static. A library variable is |
| 10663 * > implicitly static. |
| 10664 */ |
| 10665 bool get isStatic; |
| 10666 |
| 10667 /** |
| 10480 * Return the declared type of this variable, or `null` if the variable did | 10668 * Return the declared type of this variable, or `null` if the variable did |
| 10481 * not have a declared type (such as if it was declared using the keyword | 10669 * not have a declared type (such as if it was declared using the keyword |
| 10482 * 'var'). | 10670 * 'var'). |
| 10483 */ | 10671 */ |
| 10484 DartType get type; | 10672 DartType get type; |
| 10485 } | 10673 } |
| 10486 | 10674 |
| 10487 /** | 10675 /** |
| 10488 * A concrete implementation of a [VariableElement]. | 10676 * A concrete implementation of a [VariableElement]. |
| 10489 */ | 10677 */ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10542 } | 10730 } |
| 10543 | 10731 |
| 10544 /** | 10732 /** |
| 10545 * Set whether this variable is final. | 10733 * Set whether this variable is final. |
| 10546 */ | 10734 */ |
| 10547 void set final2(bool isFinal) { | 10735 void set final2(bool isFinal) { |
| 10548 setModifier(Modifier.FINAL, isFinal); | 10736 setModifier(Modifier.FINAL, isFinal); |
| 10549 } | 10737 } |
| 10550 | 10738 |
| 10551 @override | 10739 @override |
| 10740 bool get hasImplicitType => hasModifier(Modifier.IMPLICIT_TYPE); |
| 10741 |
| 10742 /** |
| 10743 * Set whether this variable element has an implicit type. |
| 10744 */ |
| 10745 void set hasImplicitType(bool hasImplicitType) { |
| 10746 setModifier(Modifier.IMPLICIT_TYPE, hasImplicitType); |
| 10747 } |
| 10748 |
| 10749 @override |
| 10552 FunctionElement get initializer => _initializer; | 10750 FunctionElement get initializer => _initializer; |
| 10553 | 10751 |
| 10554 /** | 10752 /** |
| 10555 * Set the function representing this variable's initializer to the given | 10753 * Set the function representing this variable's initializer to the given |
| 10556 * [function]. | 10754 * [function]. |
| 10557 */ | 10755 */ |
| 10558 void set initializer(FunctionElement function) { | 10756 void set initializer(FunctionElement function) { |
| 10559 if (function != null) { | 10757 if (function != null) { |
| 10560 (function as FunctionElementImpl).enclosingElement = this; | 10758 (function as FunctionElementImpl).enclosingElement = this; |
| 10561 } | 10759 } |
| 10562 this._initializer = function; | 10760 this._initializer = function; |
| 10563 } | 10761 } |
| 10564 | 10762 |
| 10565 @override | 10763 @override |
| 10566 bool get isConst => hasModifier(Modifier.CONST); | 10764 bool get isConst => hasModifier(Modifier.CONST); |
| 10567 | 10765 |
| 10568 @override | 10766 @override |
| 10569 bool get isFinal => hasModifier(Modifier.FINAL); | 10767 bool get isFinal => hasModifier(Modifier.FINAL); |
| 10570 | 10768 |
| 10571 @override | 10769 @override |
| 10572 bool get isPotentiallyMutatedInClosure => false; | 10770 bool get isPotentiallyMutatedInClosure => false; |
| 10573 | 10771 |
| 10574 @override | 10772 @override |
| 10575 bool get isPotentiallyMutatedInScope => false; | 10773 bool get isPotentiallyMutatedInScope => false; |
| 10576 | 10774 |
| 10577 @override | 10775 @override |
| 10776 bool get isStatic => hasModifier(Modifier.STATIC); |
| 10777 |
| 10778 @override |
| 10578 void appendTo(StringBuffer buffer) { | 10779 void appendTo(StringBuffer buffer) { |
| 10579 buffer.write(type); | 10780 buffer.write(type); |
| 10580 buffer.write(" "); | 10781 buffer.write(" "); |
| 10581 buffer.write(displayName); | 10782 buffer.write(displayName); |
| 10582 } | 10783 } |
| 10583 | 10784 |
| 10584 @override | 10785 @override |
| 10585 void visitChildren(ElementVisitor visitor) { | 10786 void visitChildren(ElementVisitor visitor) { |
| 10586 super.visitChildren(visitor); | 10787 super.visitChildren(visitor); |
| 10587 safelyVisitChild(_initializer, visitor); | 10788 safelyVisitChild(_initializer, visitor); |
| 10588 } | 10789 } |
| 10589 } | 10790 } |
| 10590 | 10791 |
| 10591 /** | 10792 /** |
| 10592 * A variable element defined in a parameterized type where the values of the | 10793 * A variable element defined in a parameterized type where the values of the |
| 10593 * type parameters are known. | 10794 * type parameters are known. |
| 10594 */ | 10795 */ |
| 10595 abstract class VariableMember extends Member implements VariableElement { | 10796 abstract class VariableMember extends Member implements VariableElement { |
| 10596 /** | 10797 /** |
| 10597 * Initialize a newly created element to represent a constructor, based on the | 10798 * Initialize a newly created element to represent a constructor, based on the |
| 10598 * [baseElement], defined by the [definingType]. | 10799 * [baseElement], defined by the [definingType]. |
| 10599 */ | 10800 */ |
| 10600 VariableMember(VariableElement baseElement, ParameterizedType definingType) | 10801 VariableMember(VariableElement baseElement, ParameterizedType definingType) |
| 10601 : super(baseElement, definingType); | 10802 : super(baseElement, definingType); |
| 10602 | 10803 |
| 10603 @override | 10804 @override |
| 10604 VariableElement get baseElement => super.baseElement as VariableElement; | 10805 VariableElement get baseElement => super.baseElement as VariableElement; |
| 10605 | 10806 |
| 10606 @override | 10807 @override |
| 10808 bool get hasImplicitType => baseElement.hasImplicitType; |
| 10809 |
| 10810 @override |
| 10607 FunctionElement get initializer { | 10811 FunctionElement get initializer { |
| 10608 // | 10812 // |
| 10609 // Elements within this element should have type parameters substituted, | 10813 // Elements within this element should have type parameters substituted, |
| 10610 // just like this element. | 10814 // just like this element. |
| 10611 // | 10815 // |
| 10612 throw new UnsupportedOperationException(); | 10816 throw new UnsupportedOperationException(); |
| 10613 // return getBaseElement().getInitializer(); | 10817 // return getBaseElement().getInitializer(); |
| 10614 } | 10818 } |
| 10615 | 10819 |
| 10616 @override | 10820 @override |
| 10617 bool get isConst => baseElement.isConst; | 10821 bool get isConst => baseElement.isConst; |
| 10618 | 10822 |
| 10619 @override | 10823 @override |
| 10620 bool get isFinal => baseElement.isFinal; | 10824 bool get isFinal => baseElement.isFinal; |
| 10621 | 10825 |
| 10622 @override | 10826 @override |
| 10623 bool get isPotentiallyMutatedInClosure => | 10827 bool get isPotentiallyMutatedInClosure => |
| 10624 baseElement.isPotentiallyMutatedInClosure; | 10828 baseElement.isPotentiallyMutatedInClosure; |
| 10625 | 10829 |
| 10626 @override | 10830 @override |
| 10627 bool get isPotentiallyMutatedInScope => | 10831 bool get isPotentiallyMutatedInScope => |
| 10628 baseElement.isPotentiallyMutatedInScope; | 10832 baseElement.isPotentiallyMutatedInScope; |
| 10629 | 10833 |
| 10630 @override | 10834 @override |
| 10835 bool get isStatic => baseElement.isStatic; |
| 10836 |
| 10837 @override |
| 10631 DartType get type => substituteFor(baseElement.type); | 10838 DartType get type => substituteFor(baseElement.type); |
| 10632 | 10839 |
| 10633 @override | 10840 @override |
| 10634 void visitChildren(ElementVisitor visitor) { | 10841 void visitChildren(ElementVisitor visitor) { |
| 10635 // TODO(brianwilkerson) We need to finish implementing the accessors used | 10842 // TODO(brianwilkerson) We need to finish implementing the accessors used |
| 10636 // below so that we can safely invoke them. | 10843 // below so that we can safely invoke them. |
| 10637 super.visitChildren(visitor); | 10844 super.visitChildren(visitor); |
| 10638 safelyVisitChild(baseElement.initializer, visitor); | 10845 safelyVisitChild(baseElement.initializer, visitor); |
| 10639 } | 10846 } |
| 10640 } | 10847 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10688 // bottom <: void (as bottom is a subtype of all types). | 10895 // bottom <: void (as bottom is a subtype of all types). |
| 10689 // void <: dynamic (as dynamic is a supertype of all types) | 10896 // void <: dynamic (as dynamic is a supertype of all types) |
| 10690 return identical(type, this) || type.isDynamic; | 10897 return identical(type, this) || type.isDynamic; |
| 10691 } | 10898 } |
| 10692 | 10899 |
| 10693 @override | 10900 @override |
| 10694 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; | 10901 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; |
| 10695 | 10902 |
| 10696 @override | 10903 @override |
| 10697 VoidTypeImpl substitute2( | 10904 VoidTypeImpl substitute2( |
| 10698 List<DartType> argumentTypes, List<DartType> parameterTypes, | 10905 List<DartType> argumentTypes, List<DartType> parameterTypes, |
| 10699 [List<FunctionTypeAliasElement> prune]) => this; | 10906 [List<FunctionTypeAliasElement> prune]) => |
| 10907 this; |
| 10700 } | 10908 } |
| 10701 | 10909 |
| 10702 /** | 10910 /** |
| 10703 * A visitor that visit all the elements recursively and fill the given [map]. | 10911 * A visitor that visit all the elements recursively and fill the given [map]. |
| 10704 */ | 10912 */ |
| 10705 class _BuildOffsetToElementMap extends GeneralizingElementVisitor { | 10913 class _BuildOffsetToElementMap extends GeneralizingElementVisitor { |
| 10706 final Map<int, Element> map; | 10914 final Map<int, Element> map; |
| 10707 | 10915 |
| 10708 _BuildOffsetToElementMap(this.map); | 10916 _BuildOffsetToElementMap(this.map); |
| 10709 | 10917 |
| 10710 @override | 10918 @override |
| 10711 void visitElement(Element element) { | 10919 void visitElement(Element element) { |
| 10712 int offset = element.nameOffset; | 10920 int offset = element.nameOffset; |
| 10713 if (offset != -1) { | 10921 if (offset != -1) { |
| 10714 map[offset] = element; | 10922 map[offset] = element; |
| 10715 } | 10923 } |
| 10716 super.visitElement(element); | 10924 super.visitElement(element); |
| 10717 } | 10925 } |
| 10718 } | 10926 } |
| OLD | NEW |