Find Usages: Use isEquivalenTo for PsiCompiledElement only when matching reference targets #KT-7983 Fixed
This commit is contained in:
@@ -69,8 +69,9 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
|
||||
}
|
||||
|
||||
val targets = unwrappedTargets
|
||||
if (unwrappedCandidate in targets) return true
|
||||
// TODO: Investigate why PsiCompiledElement identity changes
|
||||
if (targets.any { it.isEquivalentTo(unwrappedCandidate) }) return true
|
||||
if (unwrappedCandidate is PsiCompiledElement && targets.any { it.isEquivalentTo(unwrappedCandidate) }) return true
|
||||
|
||||
if (this is JetReference) {
|
||||
return targets.any {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.JetClass
|
||||
// OPTIONS: usages, constructorUsages
|
||||
class <caret>C {
|
||||
init {
|
||||
println("global")
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
C()
|
||||
class C {
|
||||
init {
|
||||
println("local")
|
||||
}
|
||||
}
|
||||
C()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
New instance creation (10: 5) C()
|
||||
@@ -507,6 +507,12 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("localAndNonLocalClass.0.kt")
|
||||
public void testLocalAndNonLocalClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findClassUsages/localAndNonLocalClass.0.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("primaryConstructorWithDefaultParams.0.kt")
|
||||
public void testPrimaryConstructorWithDefaultParams() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findClassUsages/primaryConstructorWithDefaultParams.0.kt");
|
||||
|
||||
Reference in New Issue
Block a user