Postpone counting fqName for anonymous classes (KT-12645)
#KT-12645 Fixed
This commit is contained in:
+3
-3
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
|
|
||||||
internal open class KtLightClassForAnonymousDeclaration(name: FqName,
|
internal open class KtLightClassForAnonymousDeclaration(fqNameFunction: ((KtClassOrObject) -> FqName),
|
||||||
classOrObject: KtClassOrObject) :
|
classOrObject: KtClassOrObject) :
|
||||||
KtLightClassForExplicitDeclaration(name, classOrObject), PsiAnonymousClass {
|
KtLightClassForExplicitDeclaration(fqNameFunction, classOrObject), PsiAnonymousClass {
|
||||||
|
|
||||||
private var cachedBaseType: SoftReference<PsiClassType>? = null
|
private var cachedBaseType: SoftReference<PsiClassType>? = null
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ internal open class KtLightClassForAnonymousDeclaration(name: FqName,
|
|||||||
override fun getTypeParameterList() = null
|
override fun getTypeParameterList() = null
|
||||||
override fun isEnum() = false
|
override fun isEnum() = false
|
||||||
|
|
||||||
override fun copy(): PsiElement = KtLightClassForAnonymousDeclaration(classFqName, classOrObject)
|
override fun copy(): PsiElement = KtLightClassForAnonymousDeclaration({ classFqName }, classOrObject)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance(KtLightClassForAnonymousDeclaration::class.java)
|
private val LOG = Logger.getInstance(KtLightClassForAnonymousDeclaration::class.java)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ internal class KtLightClassForEnumEntry(
|
|||||||
fqName: FqName,
|
fqName: FqName,
|
||||||
enumEntry: KtEnumEntry,
|
enumEntry: KtEnumEntry,
|
||||||
private val enumConstant: PsiEnumConstant
|
private val enumConstant: PsiEnumConstant
|
||||||
): KtLightClassForAnonymousDeclaration(fqName, enumEntry), PsiEnumConstantInitializer {
|
): KtLightClassForAnonymousDeclaration({ fqName }, enumEntry), PsiEnumConstantInitializer {
|
||||||
override fun getEnumConstant(): PsiEnumConstant = enumConstant
|
override fun getEnumConstant(): PsiEnumConstant = enumConstant
|
||||||
override fun copy() = KtLightClassForEnumEntry(classFqName, classOrObject as KtEnumEntry, enumConstant)
|
override fun copy() = KtLightClassForEnumEntry(classFqName, classOrObject as KtEnumEntry, enumConstant)
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-6
@@ -54,11 +54,15 @@ import java.util.*
|
|||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
open class KtLightClassForExplicitDeclaration(
|
open class KtLightClassForExplicitDeclaration(
|
||||||
protected val classFqName: FqName, // FqName of (possibly inner) class
|
private val classFqNameFunction: ((KtClassOrObject) -> FqName),
|
||||||
protected val classOrObject: KtClassOrObject)
|
protected val classOrObject: KtClassOrObject)
|
||||||
: KtWrappingLightClass(classOrObject.manager), KtJavaMirrorMarker, StubBasedPsiElement<KotlinClassOrObjectStub<out KtClassOrObject>> {
|
: KtWrappingLightClass(classOrObject.manager), KtJavaMirrorMarker, StubBasedPsiElement<KotlinClassOrObjectStub<out KtClassOrObject>> {
|
||||||
private val lightIdentifier = KtLightIdentifier(this, classOrObject)
|
private val lightIdentifier = KtLightIdentifier(this, classOrObject)
|
||||||
|
|
||||||
|
protected val classFqName : FqName by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
|
classFqNameFunction(classOrObject)
|
||||||
|
}
|
||||||
|
|
||||||
private val _extendsList by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
private val _extendsList by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
val listDelegate = super.getExtendsList() ?: return@lazy null
|
val listDelegate = super.getExtendsList() ?: return@lazy null
|
||||||
KtLightPsiReferenceList(listDelegate, this)
|
KtLightPsiReferenceList(listDelegate, this)
|
||||||
@@ -153,7 +157,7 @@ open class KtLightClassForExplicitDeclaration(
|
|||||||
override fun getFqName(): FqName = classFqName
|
override fun getFqName(): FqName = classFqName
|
||||||
|
|
||||||
override fun copy(): PsiElement {
|
override fun copy(): PsiElement {
|
||||||
return KtLightClassForExplicitDeclaration(classFqName, classOrObject.copy() as KtClassOrObject)
|
return KtLightClassForExplicitDeclaration({ classFqName }, classOrObject.copy() as KtClassOrObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val clsDelegate: PsiClass by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
override val clsDelegate: PsiClass by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
@@ -421,13 +425,18 @@ open class KtLightClassForExplicitDeclaration(
|
|||||||
|
|
||||||
|
|
||||||
fun create(classOrObject: KtClassOrObject): KtLightClassForExplicitDeclaration? {
|
fun create(classOrObject: KtClassOrObject): KtLightClassForExplicitDeclaration? {
|
||||||
val fqName = predictFqName(classOrObject) ?: return null
|
|
||||||
|
|
||||||
if (classOrObject is KtObjectDeclaration && classOrObject.isObjectLiteral()) {
|
if (classOrObject is KtObjectDeclaration && classOrObject.isObjectLiteral()) {
|
||||||
return KtLightClassForAnonymousDeclaration(fqName, classOrObject)
|
if (classOrObject.containingFile.virtualFile == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return KtLightClassForAnonymousDeclaration(
|
||||||
|
{ predictFqName(it) ?: throw IllegalArgumentException("Failed to create fqname for anonymous class: " + classOrObject) },
|
||||||
|
classOrObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
return KtLightClassForExplicitDeclaration(fqName, classOrObject)
|
val fqName = predictFqName(classOrObject) ?: return null
|
||||||
|
return KtLightClassForExplicitDeclaration({ fqName }, classOrObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun predictFqName(classOrObject: KtClassOrObject): FqName? {
|
private fun predictFqName(classOrObject: KtClassOrObject): FqName? {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtClassOrObject
|
|||||||
open class KtLightClassForInterfaceDefaultImpls(
|
open class KtLightClassForInterfaceDefaultImpls(
|
||||||
classFqName: FqName,
|
classFqName: FqName,
|
||||||
classOrObject: KtClassOrObject)
|
classOrObject: KtClassOrObject)
|
||||||
: KtLightClassForExplicitDeclaration(classFqName, classOrObject){
|
: KtLightClassForExplicitDeclaration({ classFqName }, classOrObject){
|
||||||
|
|
||||||
override fun copy(): PsiElement {
|
override fun copy(): PsiElement {
|
||||||
return KtLightClassForInterfaceDefaultImpls(classFqName, classOrObject.copy() as KtClassOrObject)
|
return KtLightClassForInterfaceDefaultImpls(classFqName, classOrObject.copy() as KtClassOrObject)
|
||||||
|
|||||||
Reference in New Issue
Block a user