Making Kotlin light elements isEquivalentTo to it's origins (KT-30583)
This commit is contained in:
+2
-1
@@ -139,7 +139,8 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
|
||||
override fun getNavigationElement(): PsiElement = classOrObject
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
return another is KtLightClassForSourceDeclaration && Comparing.equal(another.qualifiedName, qualifiedName)
|
||||
return kotlinOrigin.isEquivalentTo(another) ||
|
||||
another is KtLightClassForSourceDeclaration && Comparing.equal(another.qualifiedName, qualifiedName)
|
||||
}
|
||||
|
||||
override fun getElementIcon(flags: Int): Icon? {
|
||||
|
||||
@@ -40,4 +40,6 @@ abstract class KtLightElementBase(private val parent: PsiElement): LightElement(
|
||||
override fun getPresentation() = (kotlinOrigin ?: this).let { ItemPresentationProviders.getItemPresentation(it) }
|
||||
override fun isValid() = parent.isValid
|
||||
override fun findElementAt(offset: Int) = kotlinOrigin?.findElementAt(offset)
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean =
|
||||
super.isEquivalentTo(another) || kotlinOrigin?.isEquivalentTo(another) == true
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ abstract class KtLightMemberImpl<out D : PsiMember>(
|
||||
override fun isDeprecated() = (clsDelegate as PsiDocCommentOwner).isDeprecated
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
if (lightMemberOrigin?.originalElement?.isEquivalentTo(another) == true) return true
|
||||
|
||||
val isEquivalentByOrigin =
|
||||
another is KtLightMember<*> &&
|
||||
lightMemberOrigin?.isEquivalentTo(another.lightMemberOrigin) == true
|
||||
|
||||
@@ -102,6 +102,8 @@ class KtLightParameter(
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean {
|
||||
val result = ApplicationManager.getApplication().runReadAction(Computable {
|
||||
val kotlinOrigin = kotlinOrigin
|
||||
if (kotlinOrigin?.isEquivalentTo(another) == true) return@Computable true
|
||||
|
||||
if (another is KtLightParameter && kotlinOrigin != null) {
|
||||
kotlinOrigin == another.kotlinOrigin && clsDelegate == another.clsDelegate
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user