Change properties to methods in light class hierarchy
There's a Kotlin-Java-Kotlin hierarchy with an abstract property in a superclass and its implementation (as a get-method) in the Java subclass, which caused problems because Kotlin subclass can't have both (different symbols, same JVM signatures)
This commit is contained in:
@@ -21,5 +21,5 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||
|
||||
public trait KotlinLightClass : PsiClass, KotlinLightElement<JetClassOrObject, PsiClass> {
|
||||
val fqName: FqName
|
||||
public fun getFqName(): FqName
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
public trait KotlinLightElement<T : JetDeclaration, D : PsiElement> {
|
||||
public val origin: T?
|
||||
public val delegate: D
|
||||
public fun getOrigin(): T?
|
||||
|
||||
public fun getDelegate(): D
|
||||
}
|
||||
|
||||
+9
-5
@@ -34,8 +34,8 @@ import com.intellij.psi.util.MethodSignatureBackedByPsiMethod
|
||||
|
||||
open public class KotlinLightMethodForDeclaration(
|
||||
manager: PsiManager,
|
||||
override val delegate: PsiMethod,
|
||||
override val origin: JetDeclaration,
|
||||
private val delegate: PsiMethod,
|
||||
private val origin: JetDeclaration,
|
||||
containingClass: PsiClass
|
||||
): LightMethod(manager, delegate, containingClass), KotlinLightMethod {
|
||||
|
||||
@@ -65,8 +65,12 @@ open public class KotlinLightMethodForDeclaration(
|
||||
}, false)
|
||||
}
|
||||
|
||||
override fun getNavigationElement() : PsiElement = origin
|
||||
override fun getOriginalElement() : PsiElement = origin
|
||||
override fun getNavigationElement(): PsiElement = origin
|
||||
override fun getOriginalElement(): PsiElement = origin
|
||||
|
||||
override fun getDelegate(): PsiMethod = delegate
|
||||
|
||||
override fun getOrigin(): JetDeclaration = origin
|
||||
|
||||
override fun getParent(): PsiElement? = getContainingClass()
|
||||
|
||||
@@ -82,7 +86,7 @@ open public class KotlinLightMethodForDeclaration(
|
||||
}
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
if (another is KotlinLightMethod && origin == another.origin) {
|
||||
if (another is KotlinLightMethod && origin == another.getOrigin()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -24,11 +24,15 @@ import com.intellij.psi.PsiElement
|
||||
|
||||
public class KotlinLightMethodForTraitFakeOverride(
|
||||
manager: PsiManager,
|
||||
override val delegate: PsiMethod,
|
||||
override val origin: JetDeclaration,
|
||||
private val delegate: PsiMethod,
|
||||
private val origin: JetDeclaration,
|
||||
containingClass: PsiClass
|
||||
) : KotlinLightMethodForDeclaration(manager, delegate, origin, containingClass) {
|
||||
override fun getDelegate(): PsiMethod = delegate
|
||||
|
||||
override fun getOrigin(): JetDeclaration = origin
|
||||
|
||||
override fun copy(): PsiElement {
|
||||
return KotlinLightMethodForTraitFakeOverride(getManager()!!, delegate, origin.copy() as JetDeclaration, getContainingClass()!!)
|
||||
return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public fun JetTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||
|
||||
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
||||
public val PsiElement.unwrapped: PsiElement?
|
||||
get() = if (this is KotlinLightElement<*, *>) origin else this
|
||||
get() = if (this is KotlinLightElement<*, *>) getOrigin() else this
|
||||
|
||||
public val PsiElement.namedUnwrappedElement: PsiNamedElement?
|
||||
get() = unwrapped?.getNonStrictParentOfType<PsiNamedElement>()
|
||||
|
||||
Reference in New Issue
Block a user