Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 489173002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 /** 1002 /**
1003 * Return `true` if this class is abstract. A class is abstract if it has an e xplicit 1003 * Return `true` if this class is abstract. A class is abstract if it has an e xplicit
1004 * `abstract` modifier. Note, that this definition of <i>abstract</i> is diffe rent from 1004 * `abstract` modifier. Note, that this definition of <i>abstract</i> is diffe rent from
1005 * <i>has unimplemented members</i>. 1005 * <i>has unimplemented members</i>.
1006 * 1006 *
1007 * @return `true` if this class is abstract 1007 * @return `true` if this class is abstract
1008 */ 1008 */
1009 bool get isAbstract; 1009 bool get isAbstract;
1010 1010
1011 /** 1011 /**
1012 * Return `true` if this class is defined by an enum declaration.
1013 *
1014 * @return `true` if this class is defined by an enum declaration
1015 */
1016 bool get isEnum;
1017
1018 /**
1012 * Return `true` if this class [isProxy], or if it inherits the proxy annotati on 1019 * Return `true` if this class [isProxy], or if it inherits the proxy annotati on
1013 * from a supertype. 1020 * from a supertype.
1014 * 1021 *
1015 * @return `true` if this class defines or inherits a proxy 1022 * @return `true` if this class defines or inherits a proxy
1016 */ 1023 */
1017 bool get isOrInheritsProxy; 1024 bool get isOrInheritsProxy;
1018 1025
1019 /** 1026 /**
1020 * Return `true` if this element has an annotation of the form '@proxy'. 1027 * Return `true` if this element has an annotation of the form '@proxy'.
1021 * 1028 *
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 return true; 1475 return true;
1469 } 1476 }
1470 } 1477 }
1471 return false; 1478 return false;
1472 } 1479 }
1473 1480
1474 @override 1481 @override
1475 bool get isAbstract => hasModifier(Modifier.ABSTRACT); 1482 bool get isAbstract => hasModifier(Modifier.ABSTRACT);
1476 1483
1477 @override 1484 @override
1485 bool get isEnum => hasModifier(Modifier.ENUM);
1486
1487 @override
1478 bool get isOrInheritsProxy => _safeIsOrInheritsProxy(this, new HashSet<ClassEl ement>()); 1488 bool get isOrInheritsProxy => _safeIsOrInheritsProxy(this, new HashSet<ClassEl ement>());
1479 1489
1480 @override 1490 @override
1481 bool get isProxy { 1491 bool get isProxy {
1482 for (ElementAnnotation annotation in metadata) { 1492 for (ElementAnnotation annotation in metadata) {
1483 if (annotation.isProxy) { 1493 if (annotation.isProxy) {
1484 return true; 1494 return true;
1485 } 1495 }
1486 } 1496 }
1487 return false; 1497 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 * @param constructors the constructors contained in this class 1554 * @param constructors the constructors contained in this class
1545 */ 1555 */
1546 void set constructors(List<ConstructorElement> constructors) { 1556 void set constructors(List<ConstructorElement> constructors) {
1547 for (ConstructorElement constructor in constructors) { 1557 for (ConstructorElement constructor in constructors) {
1548 (constructor as ConstructorElementImpl).enclosingElement = this; 1558 (constructor as ConstructorElementImpl).enclosingElement = this;
1549 } 1559 }
1550 this._constructors = constructors; 1560 this._constructors = constructors;
1551 } 1561 }
1552 1562
1553 /** 1563 /**
1564 * Set whether this class is defined by an enum declaration to correspond to t he given value.
1565 *
1566 * @param isEnum `true` if the class is defined by an enum declaration
1567 */
1568 void set enum2(bool isEnum) {
1569 setModifier(Modifier.ENUM, isEnum);
1570 }
1571
1572 /**
1554 * Set the fields contained in this class to the given fields. 1573 * Set the fields contained in this class to the given fields.
1555 * 1574 *
1556 * @param fields the fields contained in this class 1575 * @param fields the fields contained in this class
1557 */ 1576 */
1558 void set fields(List<FieldElement> fields) { 1577 void set fields(List<FieldElement> fields) {
1559 for (FieldElement field in fields) { 1578 for (FieldElement field in fields) {
1560 (field as FieldElementImpl).enclosingElement = this; 1579 (field as FieldElementImpl).enclosingElement = this;
1561 } 1580 }
1562 this._fields = fields; 1581 this._fields = fields;
1563 } 1582 }
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 } 2875 }
2857 2876
2858 @override 2877 @override
2859 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this); 2878 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this);
2860 2879
2861 @override 2880 @override
2862 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 2881 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
2863 // T is S 2882 // T is S
2864 if (identical(this, type)) { 2883 if (identical(this, type)) {
2865 return true; 2884 return true;
2885 } else if (type is UnionType) {
2886 throw new NotImplementedException("No known use case");
2866 } 2887 }
2867 // else 2888 // else
2868 return withDynamic; 2889 return withDynamic;
2869 } 2890 }
2870 2891
2871 @override 2892 @override
2872 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) => true; 2893 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) => true;
2873 } 2894 }
2874 2895
2875 /** 2896 /**
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
4091 DartType get returnType; 4112 DartType get returnType;
4092 4113
4093 /** 4114 /**
4094 * Return the type of function defined by this executable element. 4115 * Return the type of function defined by this executable element.
4095 * 4116 *
4096 * @return the type of function defined by this executable element 4117 * @return the type of function defined by this executable element
4097 */ 4118 */
4098 FunctionType get type; 4119 FunctionType get type;
4099 4120
4100 /** 4121 /**
4122 * Return `true` if this executable element has body marked as being asynchron ous.
4123 *
4124 * @return `true` if this executable element has body marked as being asynchro nous
4125 */
4126 bool get isAsynchronous;
4127
4128 /**
4129 * Return `true` if this executable element has a body marked as being a gener ator.
4130 *
4131 * @return `true` if this executable element has a body marked as being a gene rator
4132 */
4133 bool get isGenerator;
4134
4135 /**
4101 * Return `true` if this executable element is an operator. The test may be ba sed on the 4136 * Return `true` if this executable element is an operator. The test may be ba sed on the
4102 * name of the executable element, in which case the result will be correct wh en the name is 4137 * name of the executable element, in which case the result will be correct wh en the name is
4103 * legal. 4138 * legal.
4104 * 4139 *
4105 * @return `true` if this executable element is an operator 4140 * @return `true` if this executable element is an operator
4106 */ 4141 */
4107 bool get isOperator; 4142 bool get isOperator;
4108 4143
4109 /** 4144 /**
4110 * Return `true` if this element is a static element. A static element is an e lement that is 4145 * Return `true` if this element is a static element. A static element is an e lement that is
4111 * not associated with a particular instance, but rather with an entire librar y or class. 4146 * not associated with a particular instance, but rather with an entire librar y or class.
4112 * 4147 *
4113 * @return `true` if this executable element is a static element 4148 * @return `true` if this executable element is a static element
4114 */ 4149 */
4115 bool get isStatic; 4150 bool get isStatic;
4151
4152 /**
4153 * Return `true` if this executable element has a body marked as being synchro nous.
4154 *
4155 * @return `true` if this executable element has a body marked as being synchr onous
4156 */
4157 bool get isSynchronous;
4116 } 4158 }
4117 4159
4118 /** 4160 /**
4119 * The abstract class `ExecutableElementImpl` implements the behavior common to 4161 * The abstract class `ExecutableElementImpl` implements the behavior common to
4120 * `ExecutableElement`s. 4162 * `ExecutableElement`s.
4121 */ 4163 */
4122 abstract class ExecutableElementImpl extends ElementImpl implements ExecutableEl ement { 4164 abstract class ExecutableElementImpl extends ElementImpl implements ExecutableEl ement {
4123 /** 4165 /**
4124 * An array containing all of the functions defined within this executable ele ment. 4166 * An array containing all of the functions defined within this executable ele ment.
4125 */ 4167 */
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4202 @override 4244 @override
4203 List<LabelElement> get labels => _labels; 4245 List<LabelElement> get labels => _labels;
4204 4246
4205 @override 4247 @override
4206 List<LocalVariableElement> get localVariables => _localVariables; 4248 List<LocalVariableElement> get localVariables => _localVariables;
4207 4249
4208 @override 4250 @override
4209 List<ParameterElement> get parameters => _parameters; 4251 List<ParameterElement> get parameters => _parameters;
4210 4252
4211 @override 4253 @override
4254 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS);
4255
4256 @override
4257 bool get isGenerator => hasModifier(Modifier.GENERATOR);
4258
4259 @override
4212 bool get isOperator => false; 4260 bool get isOperator => false;
4213 4261
4262 @override
4263 bool get isSynchronous => !hasModifier(Modifier.ASYNCHRONOUS);
4264
4214 /** 4265 /**
4215 * Set the functions defined within this executable element to the given funct ions. 4266 * Set the functions defined within this executable element to the given funct ions.
4216 * 4267 *
4217 * @param functions the functions defined within this executable element 4268 * @param functions the functions defined within this executable element
4218 */ 4269 */
4219 void set functions(List<FunctionElement> functions) { 4270 void set functions(List<FunctionElement> functions) {
4220 for (FunctionElement function in functions) { 4271 for (FunctionElement function in functions) {
4221 (function as FunctionElementImpl).enclosingElement = this; 4272 (function as FunctionElementImpl).enclosingElement = this;
4222 } 4273 }
4223 this._functions = functions; 4274 this._functions = functions;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4361 return parameterizedParameters; 4412 return parameterizedParameters;
4362 } 4413 }
4363 4414
4364 @override 4415 @override
4365 DartType get returnType => substituteFor(baseElement.returnType); 4416 DartType get returnType => substituteFor(baseElement.returnType);
4366 4417
4367 @override 4418 @override
4368 FunctionType get type => substituteFor(baseElement.type); 4419 FunctionType get type => substituteFor(baseElement.type);
4369 4420
4370 @override 4421 @override
4422 bool get isAsynchronous => baseElement.isAsynchronous;
4423
4424 @override
4425 bool get isGenerator => baseElement.isGenerator;
4426
4427 @override
4371 bool get isOperator => baseElement.isOperator; 4428 bool get isOperator => baseElement.isOperator;
4372 4429
4373 @override 4430 @override
4374 bool get isStatic => baseElement.isStatic; 4431 bool get isStatic => baseElement.isStatic;
4375 4432
4376 @override 4433 @override
4434 bool get isSynchronous => baseElement.isSynchronous;
4435
4436 @override
4377 void visitChildren(ElementVisitor visitor) { 4437 void visitChildren(ElementVisitor visitor) {
4378 // TODO(brianwilkerson) We need to finish implementing the accessors used be low so that we can 4438 // TODO(brianwilkerson) We need to finish implementing the accessors used be low so that we can
4379 // safely invoke them. 4439 // safely invoke them.
4380 super.visitChildren(visitor); 4440 super.visitChildren(visitor);
4381 safelyVisitChildren(baseElement.functions, visitor); 4441 safelyVisitChildren(baseElement.functions, visitor);
4382 safelyVisitChildren(labels, visitor); 4442 safelyVisitChildren(labels, visitor);
4383 safelyVisitChildren(baseElement.localVariables, visitor); 4443 safelyVisitChildren(baseElement.localVariables, visitor);
4384 safelyVisitChildren(parameters, visitor); 4444 safelyVisitChildren(parameters, visitor);
4385 } 4445 }
4386 } 4446 }
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 return hashCode; 5481 return hashCode;
5422 } 5482 }
5423 5483
5424 @override 5484 @override
5425 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 5485 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
5426 // trivial base cases 5486 // trivial base cases
5427 if (type == null) { 5487 if (type == null) {
5428 return false; 5488 return false;
5429 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) { 5489 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) {
5430 return true; 5490 return true;
5491 } else if (type is UnionType) {
5492 throw new NotImplementedException("No known use case");
5431 } else if (type is! FunctionType) { 5493 } else if (type is! FunctionType) {
5432 return false; 5494 return false;
5433 } else if (this == type) { 5495 } else if (this == type) {
5434 return true; 5496 return true;
5435 } 5497 }
5436 FunctionType t = this; 5498 FunctionType t = this;
5437 FunctionType s = type as FunctionType; 5499 FunctionType s = type as FunctionType;
5438 List<DartType> tTypes = t.normalParameterTypes; 5500 List<DartType> tTypes = t.normalParameterTypes;
5439 List<DartType> tOpTypes = t.optionalParameterTypes; 5501 List<DartType> tOpTypes = t.optionalParameterTypes;
5440 List<DartType> sTypes = s.normalParameterTypes; 5502 List<DartType> sTypes = s.normalParameterTypes;
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
7190 7252
7191 @override 7253 @override
7192 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 7254 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
7193 // 7255 //
7194 // S is dynamic. 7256 // S is dynamic.
7195 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of 7257 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of
7196 // InterfaceType. 7258 // InterfaceType.
7197 // 7259 //
7198 if (identical(type, DynamicTypeImpl.instance)) { 7260 if (identical(type, DynamicTypeImpl.instance)) {
7199 return true; 7261 return true;
7262 } else if (type is UnionType) {
7263 throw new NotImplementedException("No known use case");
7200 } else if (type is! InterfaceType) { 7264 } else if (type is! InterfaceType) {
7201 return false; 7265 return false;
7202 } 7266 }
7203 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>( ), withDynamic, visitedTypePairs); 7267 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>( ), withDynamic, visitedTypePairs);
7204 } 7268 }
7205 7269
7206 @override 7270 @override
7207 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) { 7271 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
7208 // 7272 //
7209 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S 7273 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
8614 * The enumeration `Modifier` defines constants for all of the modifiers defined by the Dart 8678 * The enumeration `Modifier` defines constants for all of the modifiers defined by the Dart
8615 * language and for a few additional flags that are useful. 8679 * language and for a few additional flags that are useful.
8616 */ 8680 */
8617 class Modifier extends Enum<Modifier> { 8681 class Modifier extends Enum<Modifier> {
8618 /** 8682 /**
8619 * Indicates that the modifier 'abstract' was applied to the element. 8683 * Indicates that the modifier 'abstract' was applied to the element.
8620 */ 8684 */
8621 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); 8685 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0);
8622 8686
8623 /** 8687 /**
8688 * Indicates that an executable element has a body marked as being asynchronou s.
8689 */
8690 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1);
8691
8692 /**
8624 * Indicates that the modifier 'const' was applied to the element. 8693 * Indicates that the modifier 'const' was applied to the element.
8625 */ 8694 */
8626 static const Modifier CONST = const Modifier('CONST', 1); 8695 static const Modifier CONST = const Modifier('CONST', 2);
8627 8696
8628 /** 8697 /**
8629 * Indicates that the import element represents a deferred library. 8698 * Indicates that the import element represents a deferred library.
8630 */ 8699 */
8631 static const Modifier DEFERRED = const Modifier('DEFERRED', 2); 8700 static const Modifier DEFERRED = const Modifier('DEFERRED', 3);
8701
8702 /**
8703 * Indicates that a class element was defined by an enum declaration.
8704 */
8705 static const Modifier ENUM = const Modifier('ENUM', 4);
8632 8706
8633 /** 8707 /**
8634 * Indicates that the modifier 'factory' was applied to the element. 8708 * Indicates that the modifier 'factory' was applied to the element.
8635 */ 8709 */
8636 static const Modifier FACTORY = const Modifier('FACTORY', 3); 8710 static const Modifier FACTORY = const Modifier('FACTORY', 5);
8637 8711
8638 /** 8712 /**
8639 * Indicates that the modifier 'final' was applied to the element. 8713 * Indicates that the modifier 'final' was applied to the element.
8640 */ 8714 */
8641 static const Modifier FINAL = const Modifier('FINAL', 4); 8715 static const Modifier FINAL = const Modifier('FINAL', 6);
8716
8717 /**
8718 * Indicates that an executable element has a body marked as being a generator .
8719 */
8720 static const Modifier GENERATOR = const Modifier('GENERATOR', 7);
8642 8721
8643 /** 8722 /**
8644 * Indicates that the pseudo-modifier 'get' was applied to the element. 8723 * Indicates that the pseudo-modifier 'get' was applied to the element.
8645 */ 8724 */
8646 static const Modifier GETTER = const Modifier('GETTER', 5); 8725 static const Modifier GETTER = const Modifier('GETTER', 8);
8647 8726
8648 /** 8727 /**
8649 * A flag used for libraries indicating that the defining compilation unit con tains at least one 8728 * A flag used for libraries indicating that the defining compilation unit con tains at least one
8650 * import directive whose URI uses the "dart-ext" scheme. 8729 * import directive whose URI uses the "dart-ext" scheme.
8651 */ 8730 */
8652 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 6); 8731 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 9);
8653 8732
8654 static const Modifier MIXIN = const Modifier('MIXIN', 7); 8733 /**
8734 * Indicates that a class can validly be used as a mixin.
8735 */
8736 static const Modifier MIXIN = const Modifier('MIXIN', 10);
8655 8737
8656 /** 8738 /**
8657 * Indicates that the value of a parameter or local variable might be mutated within the context. 8739 * Indicates that the value of a parameter or local variable might be mutated within the context.
8658 */ 8740 */
8659 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = const Modifier('POTENTI ALLY_MUTATED_IN_CONTEXT', 8); 8741 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = const Modifier('POTENTI ALLY_MUTATED_IN_CONTEXT', 11);
8660 8742
8661 /** 8743 /**
8662 * Indicates that the value of a parameter or local variable might be mutated within the scope. 8744 * Indicates that the value of a parameter or local variable might be mutated within the scope.
8663 */ 8745 */
8664 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = const Modifier('POTENTIAL LY_MUTATED_IN_SCOPE', 9); 8746 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = const Modifier('POTENTIAL LY_MUTATED_IN_SCOPE', 12);
8665 8747
8666 static const Modifier REFERENCES_SUPER = const Modifier('REFERENCES_SUPER', 10 ); 8748 /**
8749 * Indicates that a class contains an explicit reference to 'super'.
8750 */
8751 static const Modifier REFERENCES_SUPER = const Modifier('REFERENCES_SUPER', 13 );
8667 8752
8668 /** 8753 /**
8669 * Indicates that the pseudo-modifier 'set' was applied to the element. 8754 * Indicates that the pseudo-modifier 'set' was applied to the element.
8670 */ 8755 */
8671 static const Modifier SETTER = const Modifier('SETTER', 11); 8756 static const Modifier SETTER = const Modifier('SETTER', 14);
8672 8757
8673 /** 8758 /**
8674 * Indicates that the modifier 'static' was applied to the element. 8759 * Indicates that the modifier 'static' was applied to the element.
8675 */ 8760 */
8676 static const Modifier STATIC = const Modifier('STATIC', 12); 8761 static const Modifier STATIC = const Modifier('STATIC', 15);
8677 8762
8678 /** 8763 /**
8679 * Indicates that the element does not appear in the source code but was impli citly created. For 8764 * Indicates that the element does not appear in the source code but was impli citly created. For
8680 * example, if a class does not define any constructors, an implicit zero-argu ment constructor 8765 * example, if a class does not define any constructors, an implicit zero-argu ment constructor
8681 * will be created and it will be marked as being synthetic. 8766 * will be created and it will be marked as being synthetic.
8682 */ 8767 */
8683 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 13); 8768 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 16);
8684 8769
8685 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 14); 8770 /**
8771 * Indicates that a class was defined using an alias. TODO(brianwilkerson) Thi s should be renamed
8772 * to 'ALIAS'.
8773 */
8774 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 17);
8686 8775
8687 static const List<Modifier> values = const [ 8776 static const List<Modifier> values = const [
8688 ABSTRACT, 8777 ABSTRACT,
8778 ASYNCHRONOUS,
8689 CONST, 8779 CONST,
8690 DEFERRED, 8780 DEFERRED,
8781 ENUM,
8691 FACTORY, 8782 FACTORY,
8692 FINAL, 8783 FINAL,
8784 GENERATOR,
8693 GETTER, 8785 GETTER,
8694 HAS_EXT_URI, 8786 HAS_EXT_URI,
8695 MIXIN, 8787 MIXIN,
8696 POTENTIALLY_MUTATED_IN_CONTEXT, 8788 POTENTIALLY_MUTATED_IN_CONTEXT,
8697 POTENTIALLY_MUTATED_IN_SCOPE, 8789 POTENTIALLY_MUTATED_IN_SCOPE,
8698 REFERENCES_SUPER, 8790 REFERENCES_SUPER,
8699 SETTER, 8791 SETTER,
8700 STATIC, 8792 STATIC,
8701 SYNTHETIC, 8793 SYNTHETIC,
8702 TYPEDEF]; 8794 TYPEDEF];
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
9743 PropertyAccessorElementImpl.forNode(Identifier name) : super.forNode(name); 9835 PropertyAccessorElementImpl.forNode(Identifier name) : super.forNode(name);
9744 9836
9745 /** 9837 /**
9746 * Initialize a newly created synthetic property accessor element to be associ ated with the given 9838 * Initialize a newly created synthetic property accessor element to be associ ated with the given
9747 * variable. 9839 * variable.
9748 * 9840 *
9749 * @param variable the variable with which this access is associated 9841 * @param variable the variable with which this access is associated
9750 */ 9842 */
9751 PropertyAccessorElementImpl.forVariable(PropertyInducingElementImpl variable) : super(variable.name, variable.nameOffset) { 9843 PropertyAccessorElementImpl.forVariable(PropertyInducingElementImpl variable) : super(variable.name, variable.nameOffset) {
9752 this.variable = variable; 9844 this.variable = variable;
9845 static = variable.isStatic;
9753 synthetic = true; 9846 synthetic = true;
9754 } 9847 }
9755 9848
9756 @override 9849 @override
9757 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); 9850 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this);
9758 9851
9759 @override 9852 @override
9760 bool operator ==(Object object) => super == object && isGetter == (object as P ropertyAccessorElement).isGetter; 9853 bool operator ==(Object object) => super == object && isGetter == (object as P ropertyAccessorElement).isGetter;
9761 9854
9762 @override 9855 @override
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
10993 /** 11086 /**
10994 * The interface `UndefinedElement` defines the behavior of pseudo-elements that represent 11087 * The interface `UndefinedElement` defines the behavior of pseudo-elements that represent
10995 * names that are undefined. This situation is not allowed by the language, so o bjects implementing 11088 * names that are undefined. This situation is not allowed by the language, so o bjects implementing
10996 * this interface always represent an error. As a result, most of the normal ope rations on elements 11089 * this interface always represent an error. As a result, most of the normal ope rations on elements
10997 * do not make sense and will return useless results. 11090 * do not make sense and will return useless results.
10998 */ 11091 */
10999 abstract class UndefinedElement implements Element { 11092 abstract class UndefinedElement implements Element {
11000 } 11093 }
11001 11094
11002 /** 11095 /**
11096 * A flat immutable union of `Type`s. Here "flat" means a union type never conta ins another
11097 * union type.
11098 */
11099 abstract class UnionType implements DartType {
11100 /**
11101 * @return an immutable view of the types in this union type.
11102 */
11103 Set<DartType> get elements;
11104 }
11105
11106 /**
11107 * In addition to the methods of the `UnionType` interface we add a factory meth od
11108 * `union` for building unions.
11109 */
11110 class UnionTypeImpl extends TypeImpl implements UnionType {
11111 /**
11112 * Any unions in the `types` will be flattened in the returned union. If there is only one
11113 * type after flattening then it will be returned directly, instead of a singl eton union.
11114 *
11115 * @param types the `Type`s to union
11116 * @return a `Type` comprising the `Type`s in `types`
11117 */
11118 static DartType union(List<DartType> types) {
11119 Set<DartType> set = new HashSet<DartType>();
11120 for (DartType t in types) {
11121 if (t is UnionType) {
11122 set.addAll(t.elements);
11123 } else {
11124 set.add(t);
11125 }
11126 }
11127 if (set.length == 0) {
11128 throw new IllegalArgumentException("No known use case for empty unions.");
11129 } else if (set.length == 1) {
11130 return new JavaIterator(set).next();
11131 } else {
11132 return new UnionTypeImpl(set);
11133 }
11134 }
11135
11136 /**
11137 * The types in this union.
11138 */
11139 final Set<DartType> _types;
11140
11141 /**
11142 * This constructor should only be called by the `union` factory: it does not check that its
11143 * argument `types` contains no union types.
11144 *
11145 * @param types
11146 */
11147 UnionTypeImpl(this._types) : super(null, null);
11148
11149 @override
11150 bool operator ==(Object other) {
11151 if (other == null || other is! UnionType) {
11152 return false;
11153 } else if (identical(this, other)) {
11154 return true;
11155 } else {
11156 return javaSetEquals(this._types, (other as UnionType).elements);
11157 }
11158 }
11159
11160 @override
11161 Set<DartType> get elements => _types;
11162
11163 @override
11164 int get hashCode => this._types.hashCode;
11165
11166 @override
11167 DartType substitute2(List<DartType> argumentTypes, List<DartType> parameterTyp es) {
11168 // I can't think of any reason to substitute into a union type, since
11169 // they should only appear at the top level and not be be nested inside
11170 // other types.
11171 //
11172 // If there were a reason, then the implementation is to form a new union ty pe
11173 // by mapping the substitution over the elements of this union type.
11174 throw new NotImplementedException("No known use case.");
11175 }
11176
11177 @override
11178 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) {
11179 // TODO(collinsn): I understand why we have the [visitedElementPairs]
11180 // in subtyping definitions: the user code could have inheritance loops, e.g .
11181 //
11182 // class A extends B {}
11183 // class B extends A {}
11184 //
11185 // However, I don't see how a type equality comparison could cause a loop, s ince type
11186 // equality should be structural. For example, we have
11187 //
11188 // G<X1,...,Xm> = H<Y1,...,Yn>
11189 //
11190 // when [G = H /\ m = n /\ for all i. Xi = Yi]. Assuming there is no way to build
11191 // loopy generics (which would break [toString()]), each of the equality com parisons
11192 // above are on something structurally smaller.
11193 throw new NotImplementedException("I don't believe there is any concern abou t infinite loops in type equality comparisons.");
11194 }
11195
11196 @override
11197 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
11198 // I can't think of any reason to use [isMoreSpecificThan] for union types.
11199 throw new NotImplementedException("No known use case.");
11200 }
11201
11202 @override
11203 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
11204 // TODO(collinsn): what version of subtyping do we want?
11205 //
11206 // The more unsound version: any.
11207 /*
11208 for (Type t : this.types) {
11209 if (((TypeImpl) t).internalIsSubtypeOf(type, visitedTypePairs)) {
11210 return true;
11211 }
11212 }
11213 return false;
11214 */
11215 // The less unsound version: all.
11216 for (DartType t in this._types) {
11217 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) {
11218 return false;
11219 }
11220 }
11221 return true;
11222 }
11223
11224 /**
11225 * The super type test for union types is uniform in non-union subtypes. So, o ther
11226 * `TypeImpl`s can call this method to implement @ internalIsSubtypeOf} for un ion types.
11227 *
11228 * @param type
11229 * @param visitedTypePairs
11230 * @return true if this union type is a super type of `type`
11231 */
11232 bool internalIsSuperTypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePa irs) {
11233 // This implementation does not make sense when [type] is a union type, at l east
11234 // for the "less unsound" version of [internalIsSubtypeOf] above.
11235 if (type is UnionType) {
11236 throw new IllegalArgumentException("Only non-union types are supported.");
11237 }
11238 for (DartType t in this._types) {
11239 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) {
11240 return true;
11241 }
11242 }
11243 return false;
11244 }
11245 }
11246
11247 /**
11003 * The interface `UriReferencedElement` defines the behavior of objects included into a 11248 * The interface `UriReferencedElement` defines the behavior of objects included into a
11004 * library using some URI. 11249 * library using some URI.
11005 */ 11250 */
11006 abstract class UriReferencedElement implements Element { 11251 abstract class UriReferencedElement implements Element {
11007 /** 11252 /**
11008 * Return the offset of the character immediately following the last character of this node's URI, 11253 * Return the offset of the character immediately following the last character of this node's URI,
11009 * or `-1` for synthetic import. 11254 * or `-1` for synthetic import.
11010 * 11255 *
11011 * @return the offset of the character just past the node's URI 11256 * @return the offset of the character just past the node's URI
11012 */ 11257 */
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
11327 @override 11572 @override
11328 VoidTypeImpl substitute2(List<DartType> argumentTypes, List<DartType> paramete rTypes) => this; 11573 VoidTypeImpl substitute2(List<DartType> argumentTypes, List<DartType> paramete rTypes) => this;
11329 11574
11330 @override 11575 @override
11331 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this); 11576 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this);
11332 11577
11333 @override 11578 @override
11334 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) => isSubtypeOf(type); 11579 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) => isSubtypeOf(type);
11335 11580
11336 @override 11581 @override
11337 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) => identical(type, this) || identical(type, DynamicTypeImpl.instance); 11582 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
11583 if (type is UnionType) {
11584 throw new NotImplementedException("No known use case");
11585 }
11586 // The only subtype relations that pertain to void are therefore:
11587 // void <: void (by reflexivity)
11588 // bottom <: void (as bottom is a subtype of all types).
11589 // void <: dynamic (as dynamic is a supertype of all types)
11590 return identical(type, this) || identical(type, DynamicTypeImpl.instance);
11591 }
11338 } 11592 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698