private void createClassObjectForEnumClass( @NotNull MutableClassDescriptor mutableClassDescriptor) { if (mutableClassDescriptor.getKind() == ClassKind.ENUM_CLASS) { MutableClassDescriptor classObject = createSyntheticClassObject(mutableClassDescriptor); mutableClassDescriptor.getBuilder().setClassObjectDescriptor(classObject); classObject .getBuilder() .addFunctionDescriptor( DescriptorResolver.createEnumClassObjectValuesMethod(classObject, trace)); classObject .getBuilder() .addFunctionDescriptor( DescriptorResolver.createEnumClassObjectValueOfMethod(classObject, trace)); } }
@Override public void visitEnumEntry(@NotNull JetEnumEntry declaration) { MutableClassDescriptor descriptor = createClassDescriptorForSingleton( declaration, JetPsiUtil.safeName(declaration.getName()), ClassKind.ENUM_ENTRY); owner.addClassifierDescriptor(descriptor); descriptor.getBuilder().setClassObjectDescriptor(createSyntheticClassObject(descriptor)); }
@Override public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) { if (declaration.isObjectLiteral()) { createClassDescriptorForSingleton( declaration, SpecialNames.NO_NAME_PROVIDED, ClassKind.CLASS); return; } MutableClassDescriptor descriptor = createClassDescriptorForSingleton( declaration, JetPsiUtil.safeName(declaration.getName()), ClassKind.OBJECT); owner.addClassifierDescriptor(descriptor); trace.record(FQNAME_TO_CLASS_DESCRIPTOR, JetPsiUtil.getUnsafeFQName(declaration), descriptor); descriptor.getBuilder().setClassObjectDescriptor(createSyntheticClassObject(descriptor)); }