Load java: load annotations on enum entries

This commit is contained in:
Pavel V. Talanov
2015-12-09 17:56:18 +03:00
parent fb19552920
commit 280e00981f
7 changed files with 71 additions and 6 deletions
@@ -585,8 +585,8 @@ public class LazyJavaClassMemberScope(
if (field != null) {
EnumEntrySyntheticClassDescriptor.create(c.storageManager, ownerDescriptor, name,
c.storageManager.createLazyValue {
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({true})
}, c.components.sourceElementFactory.source(field))
memberIndex().getAllFieldNames() + memberIndex().getMethodNames({ true })
}, c.resolveAnnotations(field), c.components.sourceElementFactory.source(field))
}
else null
}
@@ -47,6 +47,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
private final MemberScope scope;
private final MemberScope staticScope = new StaticScopeForKotlinClass(this);
private final NotNullLazyValue<Collection<Name>> enumMemberNames;
private final Annotations annotations;
/**
* Creates and initializes descriptors for enum entry with the given name and its companion object
@@ -58,11 +59,12 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull ClassDescriptor enumClass,
@NotNull Name name,
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
@NotNull Annotations annotations,
@NotNull SourceElement source
) {
KotlinType enumType = enumClass.getDefaultType();
return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, enumMemberNames, source);
return new EnumEntrySyntheticClassDescriptor(storageManager, enumClass, enumType, name, enumMemberNames, annotations, source);
}
private EnumEntrySyntheticClassDescriptor(
@@ -71,11 +73,13 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull KotlinType supertype,
@NotNull Name name,
@NotNull NotNullLazyValue<Collection<Name>> enumMemberNames,
@NotNull Annotations annotations,
@NotNull SourceElement source
) {
super(storageManager, containingClass, name, source);
assert containingClass.getKind() == ClassKind.ENUM_CLASS;
this.annotations = annotations;
this.typeConstructor =
TypeConstructorImpl.createForClass(this, getAnnotations(), true, "enum entry", Collections.<TypeParameterDescriptor>emptyList(),
Collections.singleton(supertype));
@@ -160,8 +164,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
public Annotations getAnnotations() {
// TODO
return Annotations.Companion.getEMPTY();
return annotations;
}
@Override
@@ -304,7 +304,8 @@ public class DeserializedClassDescriptor(
name ->
if (name in enumEntryNames) {
EnumEntrySyntheticClassDescriptor.create(
c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE
//TODO: load annotations from class file
c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, Annotations.EMPTY, SourceElement.NO_SOURCE
)
}
else null