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
@@ -86,7 +86,11 @@ fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
}
val targets = unwrappedTargets
if (unwrappedCandidate in targets) return true
val manager = candidateTarget.manager
if (targets.any { manager.areElementsEquivalent(unwrappedCandidate, it) }) {
return true
}
if (element is KtLabelReferenceExpression && (element.parent as? KtContainerNode)?.parent is KtReturnExpression) {
targets.forEach {
@@ -97,9 +101,6 @@ fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
}
}
// TODO: Investigate why PsiCompiledElement identity changes
if (unwrappedCandidate is PsiCompiledElement && targets.any { it.isEquivalentTo(unwrappedCandidate) }) return true
if (this is KtReference) {
return targets.any {
it.isConstructorOf(unwrappedCandidate)