OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library engine.element; | 5 library engine.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/generated/utilities_general.dart'; | 9 import 'package:analyzer/src/generated/utilities_general.dart'; |
10 import 'package:analyzer/src/task/dart.dart'; | 10 import 'package:analyzer/src/task/dart.dart'; |
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4137 FieldElementImpl.forNode(Identifier name) : super.forNode(name); | 4137 FieldElementImpl.forNode(Identifier name) : super.forNode(name); |
4138 | 4138 |
4139 @override | 4139 @override |
4140 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | 4140 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
4141 | 4141 |
4142 @override | 4142 @override |
4143 bool get isEnumConstant => | 4143 bool get isEnumConstant => |
4144 enclosingElement != null ? enclosingElement.isEnum : false; | 4144 enclosingElement != null ? enclosingElement.isEnum : false; |
4145 | 4145 |
4146 @override | 4146 @override |
4147 bool get isStatic => hasModifier(Modifier.STATIC); | |
4148 | |
4149 @override | |
4150 ElementKind get kind => ElementKind.FIELD; | 4147 ElementKind get kind => ElementKind.FIELD; |
4151 | 4148 |
4152 /** | 4149 /** |
4153 * Set whether this field is static. | 4150 * Set whether this field is static. |
4154 */ | 4151 */ |
4155 void set static(bool isStatic) { | 4152 void set static(bool isStatic) { |
4156 setModifier(Modifier.STATIC, isStatic); | 4153 setModifier(Modifier.STATIC, isStatic); |
4157 } | 4154 } |
4158 | 4155 |
4159 @override | 4156 @override |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4254 ClassElement get enclosingElement => baseElement.enclosingElement; | 4251 ClassElement get enclosingElement => baseElement.enclosingElement; |
4255 | 4252 |
4256 @override | 4253 @override |
4257 PropertyAccessorElement get getter => | 4254 PropertyAccessorElement get getter => |
4258 PropertyAccessorMember.from(baseElement.getter, definingType); | 4255 PropertyAccessorMember.from(baseElement.getter, definingType); |
4259 | 4256 |
4260 @override | 4257 @override |
4261 bool get isEnumConstant => baseElement.isEnumConstant; | 4258 bool get isEnumConstant => baseElement.isEnumConstant; |
4262 | 4259 |
4263 @override | 4260 @override |
4264 bool get isStatic => baseElement.isStatic; | |
4265 | |
4266 @override | |
4267 DartType get propagatedType => substituteFor(baseElement.propagatedType); | 4261 DartType get propagatedType => substituteFor(baseElement.propagatedType); |
4268 | 4262 |
4269 @override | 4263 @override |
4270 PropertyAccessorElement get setter => | 4264 PropertyAccessorElement get setter => |
4271 PropertyAccessorMember.from(baseElement.setter, definingType); | 4265 PropertyAccessorMember.from(baseElement.setter, definingType); |
4272 | 4266 |
4273 @override | 4267 @override |
4274 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 4268 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); |
4275 | 4269 |
4276 @override | 4270 @override |
(...skipping 5248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9525 const <PropertyInducingElement>[]; | 9519 const <PropertyInducingElement>[]; |
9526 | 9520 |
9527 /** | 9521 /** |
9528 * Return the getter associated with this variable. If this variable was | 9522 * Return the getter associated with this variable. If this variable was |
9529 * explicitly defined (is not synthetic) then the getter associated with it | 9523 * explicitly defined (is not synthetic) then the getter associated with it |
9530 * will be synthetic. | 9524 * will be synthetic. |
9531 */ | 9525 */ |
9532 PropertyAccessorElement get getter; | 9526 PropertyAccessorElement get getter; |
9533 | 9527 |
9534 /** | 9528 /** |
9535 * Return `true` if this element is a static element. A static element is an | |
9536 * element that is not associated with a particular instance, but rather with | |
9537 * an entire library or class. | |
9538 */ | |
9539 bool get isStatic; | |
9540 | |
9541 /** | |
9542 * Return the propagated type of this variable, or `null` if type propagation | 9529 * Return the propagated type of this variable, or `null` if type propagation |
9543 * has not been performed, for example because the variable is not final. | 9530 * has not been performed, for example because the variable is not final. |
9544 */ | 9531 */ |
9545 DartType get propagatedType; | 9532 DartType get propagatedType; |
9546 | 9533 |
9547 /** | 9534 /** |
9548 * Return the setter associated with this variable, or `null` if the variable | 9535 * Return the setter associated with this variable, or `null` if the variable |
9549 * is effectively `final` and therefore does not have a setter associated with | 9536 * is effectively `final` and therefore does not have a setter associated with |
9550 * it. (This can happen either because the variable is explicitly defined as | 9537 * it. (This can happen either because the variable is explicitly defined as |
9551 * being `final` or because the variable is induced by an explicit getter that | 9538 * being `final` or because the variable is induced by an explicit getter that |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10530 | 10517 |
10531 /** | 10518 /** |
10532 * Return `true` if this variable is potentially mutated somewhere in its | 10519 * Return `true` if this variable is potentially mutated somewhere in its |
10533 * scope. This information is only available for local variables (including | 10520 * scope. This information is only available for local variables (including |
10534 * parameters) and only after the compilation unit containing the variable has | 10521 * parameters) and only after the compilation unit containing the variable has |
10535 * been resolved. | 10522 * been resolved. |
10536 */ | 10523 */ |
10537 bool get isPotentiallyMutatedInScope; | 10524 bool get isPotentiallyMutatedInScope; |
10538 | 10525 |
10539 /** | 10526 /** |
| 10527 * Return `true` if this element is a static variable, as per section 8 of the |
| 10528 * Dart Language Specification: |
| 10529 * |
| 10530 * > A static variable is a variable that is not associated with a particular |
| 10531 * > instance, but rather with an entire library or class. Static variables |
| 10532 * > include library variables and class variables. Class variables are |
| 10533 * > variables whose declaration is immediately nested inside a class |
| 10534 * > declaration and includes the modifier static. A library variable is |
| 10535 * > implicitly static. |
| 10536 */ |
| 10537 bool get isStatic; |
| 10538 |
| 10539 /** |
10540 * Return the declared type of this variable, or `null` if the variable did | 10540 * Return the declared type of this variable, or `null` if the variable did |
10541 * not have a declared type (such as if it was declared using the keyword | 10541 * not have a declared type (such as if it was declared using the keyword |
10542 * 'var'). | 10542 * 'var'). |
10543 */ | 10543 */ |
10544 DartType get type; | 10544 DartType get type; |
10545 } | 10545 } |
10546 | 10546 |
10547 /** | 10547 /** |
10548 * A concrete implementation of a [VariableElement]. | 10548 * A concrete implementation of a [VariableElement]. |
10549 */ | 10549 */ |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10638 @override | 10638 @override |
10639 bool get isFinal => hasModifier(Modifier.FINAL); | 10639 bool get isFinal => hasModifier(Modifier.FINAL); |
10640 | 10640 |
10641 @override | 10641 @override |
10642 bool get isPotentiallyMutatedInClosure => false; | 10642 bool get isPotentiallyMutatedInClosure => false; |
10643 | 10643 |
10644 @override | 10644 @override |
10645 bool get isPotentiallyMutatedInScope => false; | 10645 bool get isPotentiallyMutatedInScope => false; |
10646 | 10646 |
10647 @override | 10647 @override |
| 10648 bool get isStatic => hasModifier(Modifier.STATIC); |
| 10649 |
| 10650 @override |
10648 void appendTo(StringBuffer buffer) { | 10651 void appendTo(StringBuffer buffer) { |
10649 buffer.write(type); | 10652 buffer.write(type); |
10650 buffer.write(" "); | 10653 buffer.write(" "); |
10651 buffer.write(displayName); | 10654 buffer.write(displayName); |
10652 } | 10655 } |
10653 | 10656 |
10654 @override | 10657 @override |
10655 void visitChildren(ElementVisitor visitor) { | 10658 void visitChildren(ElementVisitor visitor) { |
10656 super.visitChildren(visitor); | 10659 super.visitChildren(visitor); |
10657 safelyVisitChild(_initializer, visitor); | 10660 safelyVisitChild(_initializer, visitor); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10694 | 10697 |
10695 @override | 10698 @override |
10696 bool get isPotentiallyMutatedInClosure => | 10699 bool get isPotentiallyMutatedInClosure => |
10697 baseElement.isPotentiallyMutatedInClosure; | 10700 baseElement.isPotentiallyMutatedInClosure; |
10698 | 10701 |
10699 @override | 10702 @override |
10700 bool get isPotentiallyMutatedInScope => | 10703 bool get isPotentiallyMutatedInScope => |
10701 baseElement.isPotentiallyMutatedInScope; | 10704 baseElement.isPotentiallyMutatedInScope; |
10702 | 10705 |
10703 @override | 10706 @override |
| 10707 bool get isStatic => baseElement.isStatic; |
| 10708 |
| 10709 @override |
10704 DartType get type => substituteFor(baseElement.type); | 10710 DartType get type => substituteFor(baseElement.type); |
10705 | 10711 |
10706 @override | 10712 @override |
10707 void visitChildren(ElementVisitor visitor) { | 10713 void visitChildren(ElementVisitor visitor) { |
10708 // TODO(brianwilkerson) We need to finish implementing the accessors used | 10714 // TODO(brianwilkerson) We need to finish implementing the accessors used |
10709 // below so that we can safely invoke them. | 10715 // below so that we can safely invoke them. |
10710 super.visitChildren(visitor); | 10716 super.visitChildren(visitor); |
10711 safelyVisitChild(baseElement.initializer, visitor); | 10717 safelyVisitChild(baseElement.initializer, visitor); |
10712 } | 10718 } |
10713 } | 10719 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10783 | 10789 |
10784 @override | 10790 @override |
10785 void visitElement(Element element) { | 10791 void visitElement(Element element) { |
10786 int offset = element.nameOffset; | 10792 int offset = element.nameOffset; |
10787 if (offset != -1) { | 10793 if (offset != -1) { |
10788 map[offset] = element; | 10794 map[offset] = element; |
10789 } | 10795 } |
10790 super.visitElement(element); | 10796 super.visitElement(element); |
10791 } | 10797 } |
10792 } | 10798 } |
OLD | NEW |