Class object handling refactored to emphasize the structure
This commit is contained in:
+23
-18
@@ -20,6 +20,7 @@ import com.google.common.base.Predicate;
|
|||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
@@ -205,31 +206,35 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
if (!classObjectDescriptorResolved) {
|
if (!classObjectDescriptorResolved) {
|
||||||
JetClassObject classObject = declarationProvider.getOwnerInfo().getClassObject();
|
JetClassObject classObject = declarationProvider.getOwnerInfo().getClassObject();
|
||||||
|
|
||||||
boolean isEnum = getKind() == ClassKind.ENUM_CLASS;
|
JetClassLikeInfo classObjectInfo = getClassObjectInfo(classObject);
|
||||||
JetClassLikeInfo classObjectInfo = null;
|
|
||||||
if (classObject != null) {
|
|
||||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
|
||||||
if (objectDeclaration != null) {
|
|
||||||
classObjectInfo = JetClassInfoUtil.createClassLikeInfo(objectDeclaration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (isEnum) {
|
|
||||||
// Enum classes always have class objects, and enum constants are their members
|
|
||||||
classObjectInfo = onlyEnumEntries(originalClassInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (classObjectInfo != null) {
|
if (classObjectInfo != null) {
|
||||||
classObjectDescriptor = new LazyClassDescriptor(resolveSession, this, isEnum ? Name.special("<class-object-for-" + getName() + ">") : JetPsiUtil.NO_NAME_PROVIDED,
|
Name classObjectName = getKind() == ClassKind.ENUM_CLASS
|
||||||
classObjectInfo);
|
? Name.special("<class-object-for-" + getName() + ">")
|
||||||
|
: JetPsiUtil.NO_NAME_PROVIDED;
|
||||||
|
classObjectDescriptor = new LazyClassDescriptor(resolveSession, this, classObjectName, classObjectInfo);
|
||||||
}
|
}
|
||||||
classObjectDescriptorResolved = true;
|
classObjectDescriptorResolved = true;
|
||||||
}
|
}
|
||||||
return classObjectDescriptor;
|
return classObjectDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private JetClassLikeInfo getClassObjectInfo(JetClassObject classObject) {
|
||||||
|
if (classObject != null) {
|
||||||
|
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||||
|
if (objectDeclaration != null) {
|
||||||
|
return JetClassInfoUtil.createClassLikeInfo(objectDeclaration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (getKind() == ClassKind.ENUM_CLASS) {
|
||||||
|
// Enum classes always have class objects, and enum constants are their members
|
||||||
|
return onlyEnumEntries(originalClassInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ClassKind getKind() {
|
public ClassKind getKind() {
|
||||||
|
|||||||
Reference in New Issue
Block a user