diff --git a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightClassForDecompiledDeclaration.kt b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightClassForDecompiledDeclaration.kt index 4dc1f3707b4..93e38d8e819 100644 --- a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightClassForDecompiledDeclaration.kt +++ b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightClassForDecompiledDeclaration.kt @@ -40,34 +40,21 @@ open class KtLightClassForDecompiledDeclaration( ) } - override fun getOwnMethods(): List = _methods - - override fun getOwnFields(): List = _fields - - override fun getOwnInnerClasses(): List = _innerClasses - override fun getFields(): Array = myInnersCache.fields - override fun getMethods(): Array = myInnersCache.methods - override fun getConstructors(): Array = myInnersCache.constructors - override fun getInnerClasses(): Array = myInnersCache.innerClasses - override fun findFieldByName(name: String, checkBases: Boolean): PsiField? = myInnersCache.findFieldByName(name, checkBases) - override fun findMethodsByName(name: String, checkBases: Boolean): Array = myInnersCache.findMethodsByName(name, checkBases) - override fun findInnerClassByName(name: String, checkBases: Boolean): PsiClass? = myInnersCache.findInnerClassByName(name, checkBases) - - override fun hasModifierProperty(name: String): Boolean = - clsDelegate.hasModifierProperty(name) + override fun hasModifierProperty(name: String): Boolean = clsDelegate.hasModifierProperty(name) override fun findMethodBySignature(patternMethod: PsiMethod?, checkBases: Boolean): PsiMethod? = patternMethod?.let { PsiClassImplUtil.findMethodBySignature(this, it, checkBases) } - override fun findMethodsBySignature(patternMethod: PsiMethod?, checkBases: Boolean): Array = - patternMethod?.let { PsiClassImplUtil.findMethodsBySignature(this, it, checkBases) } ?: emptyArray() + override fun findMethodsBySignature(patternMethod: PsiMethod?, checkBases: Boolean): Array = patternMethod?.let { + PsiClassImplUtil.findMethodsBySignature(this, it, checkBases) + } ?: PsiMethod.EMPTY_ARRAY override fun findMethodsAndTheirSubstitutorsByName(@NonNls name: String?, checkBases: Boolean): List> = PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases) @@ -89,77 +76,50 @@ open class KtLightClassForDecompiledDeclaration( PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiClassImplUtil.MemberType.METHOD) override fun isInterface(): Boolean = clsDelegate.isInterface - override fun getTypeParameters(): Array = clsDelegate.typeParameters - - override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean = - clsDelegate.isInheritor(baseClass, checkDeep) + override fun isInheritor(baseClass: PsiClass, checkDeep: Boolean): Boolean = clsDelegate.isInheritor(baseClass, checkDeep) override fun processDeclarations( processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement - ): Boolean { - return PsiClassImplUtil.processDeclarationsInClass( - this, processor, state, null, - lastParent, place, PsiUtil.getLanguageLevel(place), false - ) - } + ): Boolean = PsiClassImplUtil.processDeclarationsInClass( + /* aClass = */ this, + /* processor = */ processor, + /* state = */ state, + /* visited = */ null, + /* last = */ lastParent, + /* place = */ place, + /* languageLevel = */ PsiUtil.getLanguageLevel(place), + /* isRaw = */ false, + ) override fun isEnum(): Boolean = clsDelegate.isEnum - - override fun getExtendsListTypes(): Array = - PsiClassImplUtil.getExtendsListTypes(this) - + override fun getExtendsListTypes(): Array = PsiClassImplUtil.getExtendsListTypes(this) override fun getTypeParameterList(): PsiTypeParameterList? = clsDelegate.typeParameterList - override fun isAnnotationType(): Boolean = clsDelegate.isAnnotationType - override fun getNameIdentifier(): PsiIdentifier? = clsDelegate.nameIdentifier - - override fun getInterfaces(): Array = - PsiClassImplUtil.getInterfaces(this) - - override fun getSuperClass(): PsiClass? = - PsiClassImplUtil.getSuperClass(this) - - override fun getSupers(): Array = - PsiClassImplUtil.getSupers(this) - - override fun getSuperTypes(): Array = - PsiClassImplUtil.getSuperTypes(this) - - override fun getVisibleSignatures(): MutableCollection = - PsiSuperMethodImplUtil.getVisibleSignatures(this) - + override fun getInterfaces(): Array = PsiClassImplUtil.getInterfaces(this) + override fun getSuperClass(): PsiClass? = PsiClassImplUtil.getSuperClass(this) + override fun getSupers(): Array = PsiClassImplUtil.getSupers(this) + override fun getSuperTypes(): Array = PsiClassImplUtil.getSuperTypes(this) + override fun getVisibleSignatures(): Collection = PsiSuperMethodImplUtil.getVisibleSignatures(this) override fun getQualifiedName(): String? = clsDelegate.qualifiedName - - override fun getImplementsListTypes(): Array = - PsiClassImplUtil.getImplementsListTypes(this) - + override fun getImplementsListTypes(): Array = PsiClassImplUtil.getImplementsListTypes(this) override fun isDeprecated(): Boolean = clsDelegate.isDeprecated - override fun setName(name: String): PsiElement = clsDelegate.setName(name) - - override fun hasTypeParameters(): Boolean = - PsiImplUtil.hasTypeParameters(this) - + override fun hasTypeParameters(): Boolean = PsiImplUtil.hasTypeParameters(this) override fun getExtendsList(): PsiReferenceList? = clsDelegate.extendsList - override fun getDocComment(): PsiDocComment? = clsDelegate.docComment - override fun getModifierList(): PsiModifierList? = clsDelegate.modifierList - override fun getScope(): PsiElement = clsDelegate.scope - override fun getAllInnerClasses(): Array = PsiClassImplUtil.getAllInnerClasses(this) - override fun getAllMethods(): Array = PsiClassImplUtil.getAllMethods(this) - override fun getAllFields(): Array = PsiClassImplUtil.getAllFields(this) - private val _methods: List by lazyPub { + override fun getOwnMethods(): List = _ownMethods + private val _ownMethods: List by lazyPub { val isEnum = isEnum this.clsDelegate.methods.mapNotNull { psiMethod -> if (isSyntheticValuesOrValueOfMethod(psiMethod)) return@mapNotNull null @@ -175,26 +135,28 @@ open class KtLightClassForDecompiledDeclaration( } } - private val _fields: List by lazyPub { + override fun getOwnFields(): List = _ownFields + private val _ownFields: List by lazyPub { this.clsDelegate.fields.map { psiField -> - if (psiField !is PsiEnumConstant) { - KtLightFieldForDecompiledDeclaration( - fldDelegate = psiField, - fldParent = this, - lightMemberOrigin = LightMemberOriginForCompiledField(psiField, file) - ) - } else { + if (psiField is PsiEnumConstant) { KtLightEnumEntryForDecompiledDeclaration( fldDelegate = psiField, fldParent = this, lightMemberOrigin = LightMemberOriginForCompiledField(psiField, file), - file = file + file = file, + ) + } else { + KtLightFieldForDecompiledDeclaration( + fldDelegate = psiField, + fldParent = this, + lightMemberOrigin = LightMemberOriginForCompiledField(psiField, file), ) } } } - private val _innerClasses: List by lazyPub { + override fun getOwnInnerClasses(): List = _ownInnerClasses + private val _ownInnerClasses: List by lazyPub { this.clsDelegate.innerClasses.map { psiClass -> val innerDeclaration = this.kotlinOrigin ?.declarations @@ -211,24 +173,18 @@ open class KtLightClassForDecompiledDeclaration( } override val originKind: LightClassOriginKind = LightClassOriginKind.BINARY - override fun getNavigationElement() = kotlinOrigin?.navigationElement ?: file override fun equals(other: Any?): Boolean { return this === other || other is KtLightClassForDecompiledDeclaration && qualifiedName == other.qualifiedName && - kotlinOrigin?.fqName == other.kotlinOrigin?.fqName + file == other.file } override fun hashCode(): Int = qualifiedName?.hashCode() ?: kotlinOrigin?.fqName?.hashCode() ?: 0 - override fun copy(): PsiElement = this - override fun clone(): Any = this - override fun toString(): String = "${this.javaClass.simpleName} of $parent" - override fun getName(): String? = clsDelegate.name - override fun isValid(): Boolean = file.isValid && clsDelegate.isValid && (kotlinOrigin?.isValid != false) } \ No newline at end of file diff --git a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumClassForDecompiledDeclaration.kt b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumClassForDecompiledDeclaration.kt index 50060ffbad6..b29db756f2d 100644 --- a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumClassForDecompiledDeclaration.kt +++ b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumClassForDecompiledDeclaration.kt @@ -7,12 +7,13 @@ package org.jetbrains.kotlin.analysis.decompiled.light.classes import com.intellij.psi.* import org.jetbrains.kotlin.analysis.decompiler.psi.file.KtClsFile +import org.jetbrains.kotlin.asJava.classes.KtLightClass import org.jetbrains.kotlin.psi.KtClassOrObject internal class KtLightEnumClassForDecompiledDeclaration( private val psiConstantInitializer: PsiEnumConstantInitializer, private val enumConstant: KtLightEnumEntryForDecompiledDeclaration, - clsParent: KtLightClassForDecompiledDeclaration, + clsParent: KtLightClass, file: KtClsFile, kotlinOrigin: KtClassOrObject? ) : KtLightClassForDecompiledDeclaration( @@ -31,6 +32,6 @@ internal class KtLightEnumClassForDecompiledDeclaration( override fun isInQualifiedNew(): Boolean = psiConstantInitializer.isInQualifiedNew - override fun equals(other: Any?): Boolean = other is KtLightEnumClassForDecompiledDeclaration && super.equals(other) + override fun equals(other: Any?): Boolean = this === other || other is KtLightEnumClassForDecompiledDeclaration && super.equals(other) override fun hashCode(): Int = super.hashCode() } \ No newline at end of file diff --git a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumEntryForDecompiledDeclaration.kt b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumEntryForDecompiledDeclaration.kt index 8246d5ea034..48ea919fb9f 100644 --- a/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumEntryForDecompiledDeclaration.kt +++ b/analysis/decompiled/light-classes-for-decompiled/src/org/jetbrains/kotlin/analysis/decompiled/light/classes/KtLightEnumEntryForDecompiledDeclaration.kt @@ -11,33 +11,37 @@ internal class KtLightEnumEntryForDecompiledDeclaration( private val fldDelegate: PsiEnumConstant, fldParent: KtLightClassForDecompiledDeclaration, lightMemberOrigin: LightMemberOriginForCompiledField, - file: KtClsFile, + private val file: KtClsFile, ) : KtLightFieldForDecompiledDeclaration( fldDelegate, fldParent, - lightMemberOrigin + lightMemberOrigin, ), PsiEnumConstant { + override fun getArgumentList(): PsiExpressionList? = fldDelegate.argumentList + override fun resolveConstructor(): PsiMethod? = fldDelegate.resolveConstructor() + override fun resolveMethod(): PsiMethod? = fldDelegate.resolveMethod() + override fun resolveMethodGenerics(): JavaResolveResult = fldDelegate.resolveMethodGenerics() + override fun getInitializingClass(): PsiEnumConstantInitializer? = _initializingClass private val _initializingClass: PsiEnumConstantInitializer? by lazyPub { fldDelegate.initializingClass?.let { KtLightEnumClassForDecompiledDeclaration( psiConstantInitializer = it, enumConstant = this, - clsParent = fldParent, + clsParent = containingClass, file = file, - kotlinOrigin = null + kotlinOrigin = null, ) } } - override fun getArgumentList(): PsiExpressionList? = fldDelegate.argumentList - override fun resolveConstructor(): PsiMethod? = fldDelegate.resolveConstructor() - override fun resolveMethod(): PsiMethod? = fldDelegate.resolveMethod() - override fun resolveMethodGenerics(): JavaResolveResult = fldDelegate.resolveMethodGenerics() - override fun getInitializingClass(): PsiEnumConstantInitializer? = _initializingClass override fun getOrCreateInitializingClass(): PsiEnumConstantInitializer = - _initializingClass ?: error("cannot create initializing class in light enum constant") + initializingClass ?: error("cannot create initializing class in light enum constant") + + override fun equals(other: Any?): Boolean = other === this || + other is KtLightEnumEntryForDecompiledDeclaration && + containingClass == other.containingClass && + fldDelegate == other.fldDelegate - override fun equals(other: Any?): Boolean = other is KtLightEnumEntryForDecompiledDeclaration && super.equals(other) override fun hashCode(): Int = super.hashCode() } \ No newline at end of file