[light classes] move KtLightClassBase to light-classes-base module
^KT-53097
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.asJava.classes
|
||||
|
||||
import com.intellij.navigation.ItemPresentationProviders
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiField
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.impl.PsiClassImplUtil
|
||||
import com.intellij.psi.impl.light.AbstractLightClass
|
||||
import org.jetbrains.kotlin.analyzer.KotlinModificationTrackerService
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
|
||||
abstract class KtLightClassBase protected constructor(
|
||||
manager: PsiManager
|
||||
) : AbstractLightClass(manager, KotlinLanguage.INSTANCE), KtExtensibleLightClass {
|
||||
protected open val myInnersCache = KotlinClassInnerStuffCache(
|
||||
myClass = this,
|
||||
dependencies = listOf(KotlinModificationTrackerService.getInstance(manager.project).outOfBlockModificationTracker),
|
||||
lazyCreator = LightClassesLazyCreator(project)
|
||||
)
|
||||
|
||||
override fun getDelegate() = invalidAccess()
|
||||
|
||||
override fun getFields() = myInnersCache.fields
|
||||
|
||||
override fun getMethods() = myInnersCache.methods
|
||||
|
||||
override fun getConstructors() = myInnersCache.constructors
|
||||
|
||||
override fun getInnerClasses() = myInnersCache.innerClasses
|
||||
|
||||
override fun getAllFields() = PsiClassImplUtil.getAllFields(this)
|
||||
|
||||
override fun getAllMethods() = PsiClassImplUtil.getAllMethods(this)
|
||||
|
||||
override fun getAllInnerClasses() = PsiClassImplUtil.getAllInnerClasses(this)
|
||||
|
||||
override fun findFieldByName(name: String, checkBases: Boolean) = myInnersCache.findFieldByName(name, checkBases)
|
||||
|
||||
override fun findMethodsByName(name: String, checkBases: Boolean) = myInnersCache.findMethodsByName(name, checkBases)
|
||||
|
||||
override fun findInnerClassByName(name: String, checkBases: Boolean) = myInnersCache.findInnerClassByName(name, checkBases)
|
||||
abstract override fun getOwnFields(): List<PsiField>
|
||||
abstract override fun getOwnMethods(): List<PsiMethod>
|
||||
|
||||
override fun getText(): String {
|
||||
val origin = kotlinOrigin
|
||||
return if (origin == null) "" else origin.text
|
||||
}
|
||||
|
||||
override fun getLanguage() = KotlinLanguage.INSTANCE
|
||||
|
||||
override fun getPresentation() = ItemPresentationProviders.getItemPresentation(this)
|
||||
|
||||
abstract override fun equals(other: Any?): Boolean
|
||||
|
||||
abstract override fun hashCode(): Int
|
||||
|
||||
override fun getContext() = parent
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
return PsiClassImplUtil.isClassEquivalentTo(this, another)
|
||||
}
|
||||
}
|
||||
@@ -539,10 +539,6 @@ internal inline fun Project.applyCompilerPlugins(body: (UltraLightClassModifierE
|
||||
UltraLightClassModifierExtension.getInstances(this).forEach { body(it) }
|
||||
}
|
||||
|
||||
internal fun <L : Any> L.invalidAccess(): Nothing =
|
||||
error("Cls delegate shouldn't be loaded for not too complex ultra-light classes! Qualified name: ${javaClass.name}")
|
||||
|
||||
|
||||
inline fun <T> runReadAction(crossinline runnable: () -> T): T {
|
||||
return ApplicationManager.getApplication().runReadAction(Computable { runnable() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user