Misc: Use delegate with predefined name for fake light methods
#KT-21414 Fixed
This commit is contained in:
+6
-2
@@ -39,12 +39,14 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
class KtFakeLightClass(override val kotlinOrigin: KtClassOrObject) :
|
||||
AbstractLightClass(kotlinOrigin.manager, KotlinLanguage.INSTANCE),
|
||||
KtLightClass {
|
||||
private val _delegate by lazy { PsiElementFactory.SERVICE.getInstance(kotlinOrigin.project).createClass(kotlinOrigin.name ?: "") }
|
||||
private val _delegate by lazy { PsiElementFactory.SERVICE.getInstance(kotlinOrigin.project).createClass("dummy") }
|
||||
private val _containingClass by lazy { kotlinOrigin.containingClassOrObject?.let { KtFakeLightClass(it) } }
|
||||
|
||||
override val clsDelegate get() = _delegate
|
||||
override val originKind get() = LightClassOriginKind.SOURCE
|
||||
|
||||
override fun getName() = kotlinOrigin.name
|
||||
|
||||
override fun getDelegate() = _delegate
|
||||
override fun copy() = KtFakeLightClass(kotlinOrigin)
|
||||
|
||||
@@ -70,13 +72,15 @@ class KtFakeLightMethod private constructor(
|
||||
ktClassOrObject : KtClassOrObject
|
||||
) : LightMethod (
|
||||
ktDeclaration.manager,
|
||||
PsiElementFactory.SERVICE.getInstance(ktDeclaration.project).createMethod(ktDeclaration.name ?: "", PsiType.VOID),
|
||||
PsiElementFactory.SERVICE.getInstance(ktDeclaration.project).createMethod("dummy", PsiType.VOID),
|
||||
KtFakeLightClass(ktClassOrObject),
|
||||
KotlinLanguage.INSTANCE
|
||||
), KtLightElement<KtNamedDeclaration, PsiMethod> {
|
||||
override val kotlinOrigin get() = ktDeclaration
|
||||
override val clsDelegate get() = myMethod
|
||||
|
||||
override fun getName() = ktDeclaration.name ?: ""
|
||||
|
||||
override fun getNavigationElement() = ktDeclaration
|
||||
override fun getIcon(flags: Int) = ktDeclaration.getIcon(flags)
|
||||
override fun getUseScope() = ktDeclaration.useScope
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
package test
|
||||
|
||||
open class <lineMarker>SimpleParent</lineMarker> {
|
||||
open fun <lineMarker>`foo fun`</lineMarker>(n: Int) {}
|
||||
open val <lineMarker>`bar fun`</lineMarker>: Int get() = 1
|
||||
}
|
||||
|
||||
expect open class <lineMarker><lineMarker>ExpectedChild</lineMarker></lineMarker> : SimpleParent {
|
||||
override fun <lineMarker><lineMarker>`foo fun`</lineMarker></lineMarker>(n: Int)
|
||||
override val <lineMarker><lineMarker>`bar fun`</lineMarker></lineMarker>: Int
|
||||
}
|
||||
|
||||
class ExpectedChildChild : ExpectedChild() {
|
||||
override fun <lineMarker>`foo fun`</lineMarker>(n: Int) {}
|
||||
override val <lineMarker>`bar fun`</lineMarker>: Int get() = 1
|
||||
}
|
||||
|
||||
class SimpleChild : SimpleParent() {
|
||||
override fun <lineMarker>`foo fun`</lineMarker>(n: Int) {}
|
||||
override val <lineMarker>`bar fun`</lineMarker>: Int get() = 1
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !CHECK_HIGHLIGHTING
|
||||
|
||||
package test
|
||||
|
||||
actual open class ExpectedChild : SimpleParent() {
|
||||
actual override fun `foo fun`(n: Int) {}
|
||||
actual override val `bar fun`: Int get() = 1
|
||||
}
|
||||
|
||||
class ExpectedChildChildJvm : ExpectedChild() {
|
||||
override fun `foo fun`(n: Int) {}
|
||||
override val `bar fun`: Int get() = 1
|
||||
}
|
||||
@@ -90,6 +90,10 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testHierarchyWithExpectClassCommonSideNonJavaIds() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testHierarchyWithExpectClassPlatformSide() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user