Allow search usages for declarations when correct isEquivalentTo

Now it's possible to do find usages for other languages when light
elements are used.

Revert efb36f4a49 and revise fix of KT-7983:
Don't consider local and non-local class with same fqn equivalent.

 #KT-7983 Fixed
This commit is contained in:
Nikolay Krasko
2017-04-17 18:37:18 +03:00
parent eb941c75f9
commit 5dbf3b6b4d
2 changed files with 23 additions and 9 deletions
@@ -50,14 +50,27 @@ open class KtClass : KtClassOrObject {
fun isInner(): Boolean = hasModifier(KtTokens.INNER_KEYWORD)
override fun isEquivalentTo(another: PsiElement?): Boolean {
if (super.isEquivalentTo(another)) {
if (this === another) {
return true
}
if (another is KtClass) {
val fq1 = getQualifiedName()
val fq2 = another.getQualifiedName()
return fq1 != null && fq2 != null && fq1 == fq2
if (another !is KtClass) {
return false
}
val fq1 = getQualifiedName() ?: return false
val fq2 = another.getQualifiedName() ?: return false
if (fq1 == fq2) {
val thisLocal = isLocal
if (thisLocal != another.isLocal) {
return false
}
// For non-local classes same fqn is enough
// Consider different instances of local classes non-equivalent
return !thisLocal
}
return false
}