Code improvements after conversion to Kotlin
This commit is contained in:
+55
-159
@@ -26,88 +26,51 @@ import org.jetbrains.jet.lang.descriptors.impl.AbstractClassDescriptor
|
|||||||
import org.jetbrains.jet.lang.descriptors.impl.EnumEntrySyntheticClassDescriptor
|
import org.jetbrains.jet.lang.descriptors.impl.EnumEntrySyntheticClassDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorFactory
|
import org.jetbrains.jet.lang.resolve.DescriptorFactory
|
||||||
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||||
import org.jetbrains.jet.lang.resolve.name.ClassId
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name
|
import org.jetbrains.jet.lang.resolve.name.Name
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.StaticScopeForKotlinClass
|
import org.jetbrains.jet.lang.resolve.scopes.StaticScopeForKotlinClass
|
||||||
import org.jetbrains.jet.lang.types.AbstractClassTypeConstructor
|
import org.jetbrains.jet.lang.types.AbstractClassTypeConstructor
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||||
import org.jetbrains.jet.lang.types.JetType
|
import org.jetbrains.jet.lang.types.JetType
|
||||||
import org.jetbrains.jet.lang.types.TypeConstructor
|
|
||||||
import org.jetbrains.jet.storage.MemoizedFunctionToNullable
|
import org.jetbrains.jet.storage.MemoizedFunctionToNullable
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue
|
|
||||||
import org.jetbrains.jet.storage.NullableLazyValue
|
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
import org.jetbrains.jet.descriptors.serialization
|
import org.jetbrains.jet.descriptors.serialization
|
||||||
import org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName
|
import org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName
|
||||||
import org.jetbrains.jet.descriptors.serialization.classKind
|
import org.jetbrains.jet.descriptors.serialization.classKind
|
||||||
|
import org.jetbrains.jet.utils.addIfNotNull
|
||||||
|
|
||||||
|
public fun DeserializedClassDescriptor(globalContext: DeserializationGlobalContext, classData: ClassData): DeserializedClassDescriptor
|
||||||
|
= DeserializedClassDescriptor(globalContext.withNameResolver(classData.getNameResolver()), classData.getClassProto())
|
||||||
|
|
||||||
public fun DeserializedClassDescriptor(globalContext: DeserializationGlobalContext, classData: ClassData): DeserializedClassDescriptor {
|
public class DeserializedClassDescriptor(outerContext: DeserializationContext, private val classProto: ProtoBuf.Class)
|
||||||
return DeserializedClassDescriptor(globalContext.withNameResolver(classData.getNameResolver()), classData.getClassProto())
|
: AbstractClassDescriptor(outerContext.storageManager, outerContext.nameResolver.getClassId(classProto.getFqName()).getRelativeClassName().shortName()), ClassDescriptor {
|
||||||
}
|
|
||||||
|
|
||||||
public class DeserializedClassDescriptor(outerContext: DeserializationContext, private val classProto: ProtoBuf.Class) : AbstractClassDescriptor(outerContext.storageManager, outerContext.nameResolver.getClassId(classProto.getFqName()).getRelativeClassName().shortName()), ClassDescriptor {
|
private val modality = serialization.modality(Flags.MODALITY.get(classProto.getFlags()))
|
||||||
|
private val visibility = serialization.visibility(Flags.VISIBILITY.get(classProto.getFlags()))
|
||||||
|
private val kind = classKind(Flags.CLASS_KIND.get(classProto.getFlags()))
|
||||||
|
private val isInner = Flags.INNER.get(classProto.getFlags())
|
||||||
|
|
||||||
private val classId: ClassId
|
private val classId = outerContext.nameResolver.getClassId(classProto.getFqName())
|
||||||
private val memberScope: DeserializedMemberScope
|
private val typeParameters = ArrayList<TypeParameterDescriptor>(classProto.getTypeParameterCount())
|
||||||
|
private val context = outerContext.withTypes(this).childContext(this, classProto.getTypeParameterList(), typeParameters)
|
||||||
|
|
||||||
private val primaryConstructor: NullableLazyValue<ConstructorDescriptor>
|
|
||||||
|
|
||||||
private val annotations: NotNullLazyValue<Annotations>
|
|
||||||
|
|
||||||
private val classObjectDescriptor: NullableLazyValue<ClassDescriptor>
|
|
||||||
private val nestedClasses: NestedClassDescriptors
|
|
||||||
private val staticScope = StaticScopeForKotlinClass(this)
|
private val staticScope = StaticScopeForKotlinClass(this)
|
||||||
|
private val typeConstructor = DeserializedClassTypeConstructor(typeParameters)
|
||||||
|
private val memberScope = DeserializedClassMemberScope()
|
||||||
|
private val nestedClasses = NestedClassDescriptors()
|
||||||
|
|
||||||
private val containingDeclaration: NotNullLazyValue<DeclarationDescriptor>
|
private val containingDeclaration = outerContext.storageManager.createLazyValue { computeContainingDeclaration() }
|
||||||
private val typeConstructor: DeserializedClassTypeConstructor
|
private val annotations = context.storageManager.createLazyValue { computeAnnotations() }
|
||||||
private val modality: Modality
|
private val primaryConstructor = context.storageManager.createNullableLazyValue { computePrimaryConstructor() }
|
||||||
private val visibility: Visibility
|
private val classObjectDescriptor = context.storageManager.createNullableLazyValue { computeClassObjectDescriptor() }
|
||||||
private val kind: ClassKind
|
|
||||||
private val isInner: Boolean
|
|
||||||
private val context: DeserializationContextWithTypes
|
|
||||||
|
|
||||||
{
|
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration()
|
||||||
this.classId = outerContext.nameResolver.getClassId(classProto.getFqName())
|
|
||||||
|
|
||||||
val typeParameters = ArrayList<TypeParameterDescriptor>(classProto.getTypeParameterCount())
|
|
||||||
this.context = outerContext.withTypes(this).childContext(this, classProto.getTypeParameterList(), typeParameters)
|
|
||||||
|
|
||||||
this.containingDeclaration = outerContext.storageManager.createLazyValue<DeclarationDescriptor>(object : Function0<DeclarationDescriptor> {
|
|
||||||
override fun invoke(): DeclarationDescriptor {
|
|
||||||
return computeContainingDeclaration()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.typeConstructor = DeserializedClassTypeConstructor(typeParameters)
|
|
||||||
this.memberScope = DeserializedClassMemberScope()
|
|
||||||
|
|
||||||
val flags = classProto.getFlags()
|
|
||||||
this.modality = serialization.modality(Flags.MODALITY.get(flags))
|
|
||||||
this.visibility = serialization.visibility(Flags.VISIBILITY.get(flags))
|
|
||||||
this.kind = classKind(Flags.CLASS_KIND.get(flags))
|
|
||||||
this.isInner = Flags.INNER.get(flags)
|
|
||||||
|
|
||||||
this.annotations = context.storageManager.createLazyValue<Annotations> { computeAnnotations() }
|
|
||||||
|
|
||||||
this.primaryConstructor = context.storageManager.createNullableLazyValue<ConstructorDescriptor> { computePrimaryConstructor() }
|
|
||||||
|
|
||||||
this.classObjectDescriptor = context.storageManager.createNullableLazyValue<ClassDescriptor> { computeClassObjectDescriptor() }
|
|
||||||
|
|
||||||
this.nestedClasses = NestedClassDescriptors()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
|
||||||
return containingDeclaration.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun computeContainingDeclaration(): DeclarationDescriptor {
|
private fun computeContainingDeclaration(): DeclarationDescriptor {
|
||||||
if (classId.isTopLevelClass()) {
|
if (classId.isTopLevelClass()) {
|
||||||
val fragments = context.packageFragmentProvider.getPackageFragments(classId.getPackageFqName())
|
val fragments = context.packageFragmentProvider.getPackageFragments(classId.getPackageFqName())
|
||||||
assert(fragments.size() == 1) { "there should be exactly one package: " + fragments + ", class id is " + classId }
|
assert(fragments.size() == 1) { "there should be exactly one package: $fragments, class id is $classId" }
|
||||||
return fragments.iterator().next()
|
return fragments.iterator().next()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -115,26 +78,15 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTypeConstructor(): TypeConstructor {
|
override fun getTypeConstructor() = typeConstructor
|
||||||
return typeConstructor
|
|
||||||
}
|
|
||||||
|
|
||||||
|
override fun getKind() = kind
|
||||||
|
|
||||||
override fun getKind(): ClassKind {
|
override fun getModality() = modality
|
||||||
return kind
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getModality(): Modality {
|
override fun getVisibility() = visibility
|
||||||
return modality
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getVisibility(): Visibility {
|
override fun isInner() = isInner
|
||||||
return visibility
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isInner(): Boolean {
|
|
||||||
return isInner
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun computeAnnotations(): Annotations {
|
private fun computeAnnotations(): Annotations {
|
||||||
if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
|
if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
|
||||||
@@ -143,17 +95,11 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
return context.annotationLoader.loadClassAnnotations(this, classProto)
|
return context.annotationLoader.loadClassAnnotations(this, classProto)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAnnotations(): Annotations {
|
override fun getAnnotations(): Annotations = annotations()
|
||||||
return annotations.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getScopeForMemberLookup(): JetScope {
|
override fun getScopeForMemberLookup() = memberScope
|
||||||
return memberScope
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStaticScope(): JetScope {
|
override fun getStaticScope() = staticScope
|
||||||
return staticScope
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun computePrimaryConstructor(): ConstructorDescriptor? {
|
private fun computePrimaryConstructor(): ConstructorDescriptor? {
|
||||||
if (!classProto.hasPrimaryConstructor()) return null
|
if (!classProto.hasPrimaryConstructor()) return null
|
||||||
@@ -168,28 +114,21 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
return context.deserializer.loadCallable(constructorProto.getData()) as ConstructorDescriptor
|
return context.deserializer.loadCallable(constructorProto.getData()) as ConstructorDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? {
|
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||||
return primaryConstructor.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getConstructors(): Collection<ConstructorDescriptor> {
|
override fun getConstructors(): Collection<ConstructorDescriptor> {
|
||||||
val constructor = getUnsubstitutedPrimaryConstructor()
|
val constructor = getUnsubstitutedPrimaryConstructor() ?: return listOf()
|
||||||
if (constructor == null) {
|
|
||||||
return listOf()
|
|
||||||
}
|
|
||||||
// TODO: other constructors
|
// TODO: other constructors
|
||||||
return listOf(constructor)
|
return listOf(constructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computeClassObjectDescriptor(): ClassDescriptor? {
|
private fun computeClassObjectDescriptor(): ClassDescriptor? {
|
||||||
if (!classProto.hasClassObject()) {
|
if (!classProto.hasClassObject()) return null
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getKind() == ClassKind.OBJECT) {
|
if (getKind() == ClassKind.OBJECT) {
|
||||||
val classObjectProto = classProto.getClassObject()
|
val classObjectProto = classProto.getClassObject()
|
||||||
if (!classObjectProto.hasData()) {
|
if (!classObjectProto.hasData()) {
|
||||||
throw IllegalStateException("Object should have a serialized class object: " + classId)
|
throw IllegalStateException("Object should have a serialized class object: $classId")
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeserializedClassDescriptor(context, classObjectProto.getData())
|
return DeserializedClassDescriptor(context, classObjectProto.getData())
|
||||||
@@ -198,9 +137,7 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
return context.deserializeClass(classId.createNestedClassId(getClassObjectName(getName())))
|
return context.deserializeClass(classId.createNestedClassId(getClassObjectName(getName())))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getClassObjectDescriptor(): ClassDescriptor? {
|
override fun getClassObjectDescriptor(): ClassDescriptor? = classObjectDescriptor()
|
||||||
return classObjectDescriptor.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun computeSuperTypes(): Collection<JetType> {
|
private fun computeSuperTypes(): Collection<JetType> {
|
||||||
val supertypes = ArrayList<JetType>(classProto.getSupertypeCount())
|
val supertypes = ArrayList<JetType>(classProto.getSupertypeCount())
|
||||||
@@ -210,21 +147,14 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
return supertypes
|
return supertypes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString() = "deserialized class ${getName().toString()}" // not using descriptor render to preserve laziness
|
||||||
// not using descriptor render to preserve laziness
|
|
||||||
return "deserialized class " + getName().toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSource(): SourceElement {
|
override fun getSource() = SourceElement.NO_SOURCE
|
||||||
return SourceElement.NO_SOURCE
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class DeserializedClassTypeConstructor(private val parameters: List<TypeParameterDescriptor>) : AbstractClassTypeConstructor() {
|
private inner class DeserializedClassTypeConstructor(private val parameters: List<TypeParameterDescriptor>) : AbstractClassTypeConstructor() {
|
||||||
private val supertypes = computeSuperTypes()
|
private val supertypes = computeSuperTypes()
|
||||||
|
|
||||||
override fun getParameters(): List<TypeParameterDescriptor> {
|
override fun getParameters() = parameters
|
||||||
return parameters
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSupertypes(): Collection<JetType> {
|
override fun getSupertypes(): Collection<JetType> {
|
||||||
// We cannot have error supertypes because subclasses inherit error functions from them
|
// We cannot have error supertypes because subclasses inherit error functions from them
|
||||||
@@ -237,33 +167,19 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
return supertypes
|
return supertypes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isFinal(): Boolean {
|
override fun isFinal() = !getModality().isOverridable()
|
||||||
return !getModality().isOverridable()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isDenotable(): Boolean {
|
override fun isDenotable() = true
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDeclarationDescriptor(): ClassifierDescriptor? {
|
override fun getDeclarationDescriptor() = this@DeserializedClassDescriptor
|
||||||
return this@DeserializedClassDescriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAnnotations(): Annotations {
|
override fun getAnnotations(): Annotations = Annotations.EMPTY // TODO
|
||||||
return Annotations.EMPTY // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString() = getName().toString()
|
||||||
return getName().toString()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class DeserializedClassMemberScope : DeserializedMemberScope(context, this@DeserializedClassDescriptor.classProto.getMemberList()) {
|
private inner class DeserializedClassMemberScope : DeserializedMemberScope(context, this@DeserializedClassDescriptor.classProto.getMemberList()) {
|
||||||
private val classDescriptor: DeserializedClassDescriptor
|
private val classDescriptor: DeserializedClassDescriptor = this@DeserializedClassDescriptor
|
||||||
|
|
||||||
{
|
|
||||||
this.classDescriptor = this@DeserializedClassDescriptor
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
|
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
|
||||||
val fromSupertypes = ArrayList<FunctionDescriptor>()
|
val fromSupertypes = ArrayList<FunctionDescriptor>()
|
||||||
@@ -273,13 +189,13 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
generateFakeOverrides(name, fromSupertypes, functions)
|
generateFakeOverrides(name, fromSupertypes, functions)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun computeNonDeclaredProperties(name: Name, property: MutableCollection<PropertyDescriptor>) {
|
override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||||
val fromSupertypes = ArrayList<PropertyDescriptor>()
|
val fromSupertypes = ArrayList<PropertyDescriptor>()
|
||||||
for (supertype in classDescriptor.getTypeConstructor().getSupertypes()) {
|
for (supertype in classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||||
[suppress("UNCHECKED_CAST")]
|
[suppress("UNCHECKED_CAST")]
|
||||||
fromSupertypes.addAll(supertype.getMemberScope().getProperties(name) as Collection<PropertyDescriptor>)
|
fromSupertypes.addAll(supertype.getMemberScope().getProperties(name) as Collection<PropertyDescriptor>)
|
||||||
}
|
}
|
||||||
generateFakeOverrides(name, fromSupertypes, property)
|
generateFakeOverrides(name, fromSupertypes, descriptors)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : CallableMemberDescriptor> generateFakeOverrides(name: Name, fromSupertypes: Collection<D>, result: MutableCollection<D>) {
|
private fun <D : CallableMemberDescriptor> generateFakeOverrides(name: Name, fromSupertypes: Collection<D>, result: MutableCollection<D>) {
|
||||||
@@ -312,13 +228,9 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getImplicitReceiver(): ReceiverParameterDescriptor? {
|
override fun getImplicitReceiver() = classDescriptor.getThisAsReceiverParameter()
|
||||||
return classDescriptor.getThisAsReceiverParameter()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getClassDescriptor(name: Name): ClassifierDescriptor? {
|
override fun getClassDescriptor(name: Name): ClassifierDescriptor? = classDescriptor.nestedClasses.findClass(name)
|
||||||
return classDescriptor.nestedClasses.findClass.invoke(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun addAllClassDescriptors(result: MutableCollection<DeclarationDescriptor>) {
|
override fun addAllClassDescriptors(result: MutableCollection<DeclarationDescriptor>) {
|
||||||
result.addAll(classDescriptor.nestedClasses.getAllDescriptors())
|
result.addAll(classDescriptor.nestedClasses.getAllDescriptors())
|
||||||
@@ -326,22 +238,14 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inner class NestedClassDescriptors {
|
private inner class NestedClassDescriptors {
|
||||||
private val nestedClassNames: Set<Name>
|
private val nestedClassNames = nestedClassNames()
|
||||||
val findClass: MemoizedFunctionToNullable<Name, ClassDescriptor>
|
private val enumEntryNames = enumEntryNames()
|
||||||
private val enumEntryNames: Set<Name>
|
|
||||||
|
|
||||||
{
|
|
||||||
this.nestedClassNames = nestedClassNames()
|
|
||||||
this.enumEntryNames = enumEntryNames()
|
|
||||||
|
|
||||||
|
val findClass: MemoizedFunctionToNullable<Name, ClassDescriptor> = run {
|
||||||
val storageManager = context.storageManager
|
val storageManager = context.storageManager
|
||||||
val enumMemberNames = storageManager.createLazyValue<Collection<Name>>(object : Function0<Collection<Name>> {
|
val enumMemberNames = storageManager.createLazyValue { computeEnumMemberNames() }
|
||||||
override fun invoke(): Collection<Name> {
|
|
||||||
return computeEnumMemberNames()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.findClass = storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> { name ->
|
storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> { name ->
|
||||||
if (enumEntryNames.contains(name)) {
|
if (enumEntryNames.contains(name)) {
|
||||||
EnumEntrySyntheticClassDescriptor.create(storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE)
|
EnumEntrySyntheticClassDescriptor.create(storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, SourceElement.NO_SOURCE)
|
||||||
}
|
}
|
||||||
@@ -364,9 +268,7 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun enumEntryNames(): Set<Name> {
|
private fun enumEntryNames(): Set<Name> {
|
||||||
if (getKind() != ClassKind.ENUM_CLASS) {
|
if (getKind() != ClassKind.ENUM_CLASS) return setOf()
|
||||||
return setOf()
|
|
||||||
}
|
|
||||||
|
|
||||||
val result = HashSet<Name>()
|
val result = HashSet<Name>()
|
||||||
val nameResolver = context.nameResolver
|
val nameResolver = context.nameResolver
|
||||||
@@ -394,16 +296,10 @@ public class DeserializedClassDescriptor(outerContext: DeserializationContext, p
|
|||||||
public fun getAllDescriptors(): Collection<ClassDescriptor> {
|
public fun getAllDescriptors(): Collection<ClassDescriptor> {
|
||||||
val result = ArrayList<ClassDescriptor>(nestedClassNames.size() + enumEntryNames.size())
|
val result = ArrayList<ClassDescriptor>(nestedClassNames.size() + enumEntryNames.size())
|
||||||
for (name in nestedClassNames) {
|
for (name in nestedClassNames) {
|
||||||
val descriptor = findClass.invoke(name)
|
result.addIfNotNull(findClass(name))
|
||||||
if (descriptor != null) {
|
|
||||||
result.add(descriptor)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (name in enumEntryNames) {
|
for (name in enumEntryNames) {
|
||||||
val descriptor = findClass.invoke(name)
|
result.addIfNotNull(findClass(name))
|
||||||
if (descriptor != null) {
|
|
||||||
result.add(descriptor)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user