Make Kotlin light class more like PsiAnonymousClassImpl
Avoid delegating to cls delegate in more places
This commit is contained in:
+12
-5
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.InheritanceImplUtil
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.reference.SoftReference
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -35,10 +34,6 @@ internal open class KtLightClassForAnonymousDeclaration(name: FqName,
|
||||
return JavaPsiFacade.getElementFactory(classOrObject.project).createReferenceElementByType(baseClassType)
|
||||
}
|
||||
|
||||
override fun getContainingClass(): PsiClass? {
|
||||
return delegate.containingClass
|
||||
}
|
||||
|
||||
private val firstSupertypeFQName: String
|
||||
get() {
|
||||
val descriptor = getDescriptor() ?: return CommonClassNames.JAVA_LANG_OBJECT
|
||||
@@ -104,6 +99,18 @@ internal open class KtLightClassForAnonymousDeclaration(name: FqName,
|
||||
return classOrObject.hashCode()
|
||||
}
|
||||
|
||||
override fun getNameIdentifier() = null
|
||||
override fun getQualifiedName(): String? = null
|
||||
override fun getModifierList(): PsiModifierList? = null
|
||||
override fun hasModifierProperty(name: String): Boolean = name == PsiModifier.FINAL
|
||||
override fun getExtendsList(): PsiReferenceList? = null
|
||||
override fun getImplementsList(): PsiReferenceList? = null
|
||||
override fun getContainingClass(): PsiClass? = null
|
||||
override fun isInterface() = false
|
||||
override fun isAnnotationType() = false
|
||||
override fun getTypeParameterList() = null
|
||||
override fun isEnum() = false
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(KtLightClassForAnonymousDeclaration::class.java)
|
||||
}
|
||||
|
||||
+4
-4
@@ -254,7 +254,7 @@ open class KtLightClassForExplicitDeclaration(
|
||||
|
||||
override fun getName(): String? = classFqName.shortName().asString()
|
||||
|
||||
override fun getQualifiedName(): String = classFqName.asString()
|
||||
override fun getQualifiedName(): String? = classFqName.asString()
|
||||
|
||||
private val _modifierList : PsiModifierList by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
object : KtLightModifierListWithExplicitModifiers(this@KtLightClassForExplicitDeclaration, computeModifiers()) {
|
||||
@@ -263,7 +263,7 @@ open class KtLightClassForExplicitDeclaration(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getModifierList(): PsiModifierList = _modifierList
|
||||
override fun getModifierList(): PsiModifierList? = _modifierList
|
||||
|
||||
protected open fun computeModifiers(): Array<String> {
|
||||
val psiModifiers = hashSetOf<String>()
|
||||
@@ -306,7 +306,7 @@ open class KtLightClassForExplicitDeclaration(
|
||||
|
||||
private fun isSealed(): Boolean = classOrObject.hasModifier(SEALED_KEYWORD)
|
||||
|
||||
override fun hasModifierProperty(@NonNls name: String): Boolean = modifierList.hasModifierProperty(name)
|
||||
override fun hasModifierProperty(@NonNls name: String): Boolean = modifierList?.hasModifierProperty(name) ?: false
|
||||
|
||||
override fun isDeprecated(): Boolean {
|
||||
val jetModifierList = classOrObject.modifierList ?: return false
|
||||
@@ -392,7 +392,7 @@ open class KtLightClassForExplicitDeclaration(
|
||||
override fun getElementType(): IStubElementType<out StubElement<*>, *>? = classOrObject.elementType
|
||||
override fun getStub(): KotlinClassOrObjectStub<out KtClassOrObject>? = classOrObject.stub
|
||||
|
||||
override fun getNameIdentifier() = lightIdentifier
|
||||
override fun getNameIdentifier(): KtLightIdentifier? = lightIdentifier
|
||||
|
||||
companion object {
|
||||
private val JAVA_API_STUB = Key.create<CachedValue<WithFileStubAndExtraDiagnostics>>("JAVA_API_STUB")
|
||||
|
||||
Reference in New Issue
Block a user