Add a flag to the element model to identify mixin applications.
R=brianwilkerson@google.com Review URL: https://codereview.chromium.org//1120623003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45495 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -177,6 +177,12 @@ abstract class ClassElement implements Element {
|
||||
*/
|
||||
bool get isEnum;
|
||||
|
||||
/**
|
||||
* Return `true` if this class is a mixin application. A class is a mixin
|
||||
* application if it was declared using the syntax "class A = B with C;".
|
||||
*/
|
||||
bool get isMixinApplication;
|
||||
|
||||
/**
|
||||
* Return `true` if this class [isProxy], or if it inherits the proxy
|
||||
* annotation from a supertype.
|
||||
@@ -659,6 +665,9 @@ class ClassElementImpl extends ElementImpl implements ClassElement {
|
||||
@override
|
||||
bool get isEnum => hasModifier(Modifier.ENUM);
|
||||
|
||||
@override
|
||||
bool get isMixinApplication => hasModifier(Modifier.MIXIN_APPLICATION);
|
||||
|
||||
@override
|
||||
bool get isOrInheritsProxy =>
|
||||
_safeIsOrInheritsProxy(this, new HashSet<ClassElement>());
|
||||
@@ -695,6 +704,13 @@ class ClassElementImpl extends ElementImpl implements ClassElement {
|
||||
this._methods = methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this class is a mixin application.
|
||||
*/
|
||||
void set mixinApplication(bool isMixinApplication) {
|
||||
setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
|
||||
}
|
||||
|
||||
bool get mixinErrorsReported => hasModifier(Modifier.MIXIN_ERRORS_REPORTED);
|
||||
|
||||
/**
|
||||
@@ -7921,42 +7937,48 @@ class Modifier extends Enum<Modifier> {
|
||||
*/
|
||||
static const Modifier MIXIN = const Modifier('MIXIN', 10);
|
||||
|
||||
/**
|
||||
* Indicates that a class is a mixin application.
|
||||
*/
|
||||
static const Modifier MIXIN_APPLICATION =
|
||||
const Modifier('MIXIN_APPLICATION', 11);
|
||||
|
||||
/**
|
||||
* Indicates that an error has reported explaining why this class is an
|
||||
* invalid mixin application.
|
||||
*/
|
||||
static const Modifier MIXIN_ERRORS_REPORTED =
|
||||
const Modifier('MIXIN_ERRORS_REPORTED', 11);
|
||||
const Modifier('MIXIN_ERRORS_REPORTED', 12);
|
||||
|
||||
/**
|
||||
* Indicates that the value of a parameter or local variable might be mutated
|
||||
* within the context.
|
||||
*/
|
||||
static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT =
|
||||
const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 12);
|
||||
const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13);
|
||||
|
||||
/**
|
||||
* Indicates that the value of a parameter or local variable might be mutated
|
||||
* within the scope.
|
||||
*/
|
||||
static const Modifier POTENTIALLY_MUTATED_IN_SCOPE =
|
||||
const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 13);
|
||||
const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14);
|
||||
|
||||
/**
|
||||
* Indicates that a class contains an explicit reference to 'super'.
|
||||
*/
|
||||
static const Modifier REFERENCES_SUPER =
|
||||
const Modifier('REFERENCES_SUPER', 14);
|
||||
const Modifier('REFERENCES_SUPER', 15);
|
||||
|
||||
/**
|
||||
* Indicates that the pseudo-modifier 'set' was applied to the element.
|
||||
*/
|
||||
static const Modifier SETTER = const Modifier('SETTER', 15);
|
||||
static const Modifier SETTER = const Modifier('SETTER', 16);
|
||||
|
||||
/**
|
||||
* Indicates that the modifier 'static' was applied to the element.
|
||||
*/
|
||||
static const Modifier STATIC = const Modifier('STATIC', 16);
|
||||
static const Modifier STATIC = const Modifier('STATIC', 17);
|
||||
|
||||
/**
|
||||
* Indicates that the element does not appear in the source code but was
|
||||
@@ -7964,13 +7986,13 @@ class Modifier extends Enum<Modifier> {
|
||||
* constructors, an implicit zero-argument constructor will be created and it
|
||||
* will be marked as being synthetic.
|
||||
*/
|
||||
static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17);
|
||||
static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18);
|
||||
|
||||
/**
|
||||
* Indicates that a class was defined using an alias.
|
||||
* TODO(brianwilkerson) This should be renamed to 'ALIAS'.
|
||||
*/
|
||||
static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18);
|
||||
static const Modifier TYPEDEF = const Modifier('TYPEDEF', 19);
|
||||
|
||||
static const List<Modifier> values = const [
|
||||
ABSTRACT,
|
||||
@@ -7984,6 +8006,7 @@ class Modifier extends Enum<Modifier> {
|
||||
GETTER,
|
||||
HAS_EXT_URI,
|
||||
MIXIN,
|
||||
MIXIN_APPLICATION,
|
||||
MIXIN_ERRORS_REPORTED,
|
||||
POTENTIALLY_MUTATED_IN_CONTEXT,
|
||||
POTENTIALLY_MUTATED_IN_SCOPE,
|
||||
|
||||
@@ -60,6 +60,9 @@ class ClassElementHandle extends ElementHandle implements ClassElement {
|
||||
@override
|
||||
bool get isEnum => actualElement.isEnum;
|
||||
|
||||
@override
|
||||
bool get isMixinApplication => actualElement.isMixinApplication;
|
||||
|
||||
@override
|
||||
bool get isOrInheritsProxy => actualElement.isOrInheritsProxy;
|
||||
|
||||
|
||||
@@ -2487,6 +2487,7 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
||||
SimpleIdentifier className = node.name;
|
||||
ClassElementImpl element = new ClassElementImpl.forNode(className);
|
||||
element.abstract = node.abstractKeyword != null;
|
||||
element.mixinApplication = true;
|
||||
element.typedef = true;
|
||||
List<TypeParameterElement> typeParameters = holder.typeParameters;
|
||||
element.typeParameters = typeParameters;
|
||||
|
||||
@@ -4963,6 +4963,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
List<TypeParameterElement> typeParameters = type.typeParameters;
|
||||
expect(typeParameters, hasLength(0));
|
||||
expect(type.isAbstract, isTrue);
|
||||
expect(type.isMixinApplication, isFalse);
|
||||
expect(type.isSynthetic, isFalse);
|
||||
}
|
||||
|
||||
@@ -4981,6 +4982,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
List<TypeParameterElement> typeParameters = type.typeParameters;
|
||||
expect(typeParameters, hasLength(0));
|
||||
expect(type.isAbstract, isFalse);
|
||||
expect(type.isMixinApplication, isFalse);
|
||||
expect(type.isSynthetic, isFalse);
|
||||
}
|
||||
|
||||
@@ -5005,6 +5007,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
expect(typeParameters[0].name, firstVariableName);
|
||||
expect(typeParameters[1].name, secondVariableName);
|
||||
expect(type.isAbstract, isFalse);
|
||||
expect(type.isMixinApplication, isFalse);
|
||||
expect(type.isSynthetic, isFalse);
|
||||
}
|
||||
|
||||
@@ -5031,6 +5034,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
expect(type, isNotNull);
|
||||
expect(type.name, className);
|
||||
expect(type.isAbstract, isFalse);
|
||||
expect(type.isMixinApplication, isFalse);
|
||||
expect(type.isSynthetic, isFalse);
|
||||
List<TypeParameterElement> typeParameters = type.typeParameters;
|
||||
expect(typeParameters, hasLength(1));
|
||||
@@ -5072,6 +5076,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
expect(alias.element, same(type));
|
||||
expect(type.name, equals('C'));
|
||||
expect(type.isAbstract, isFalse);
|
||||
expect(type.isMixinApplication, isTrue);
|
||||
expect(type.isSynthetic, isFalse);
|
||||
expect(type.typeParameters, isEmpty);
|
||||
expect(type.fields, isEmpty);
|
||||
@@ -5099,6 +5104,7 @@ class ElementBuilderTest extends EngineTestCase {
|
||||
expect(types, hasLength(1));
|
||||
ClassElement type = types[0];
|
||||
expect(type.isAbstract, isTrue);
|
||||
expect(type.isMixinApplication, isTrue);
|
||||
}
|
||||
|
||||
void test_visitClassTypeAlias_typeParams() {
|
||||
|
||||
Reference in New Issue
Block a user