[kotlin] find usages: process references from enum entries to enum primary constructor

^KTIJ-29756 fixed

GitOrigin-RevId: 800ff40cdb031c3229bd7a1152d6913c3b3a26dd
This commit is contained in:
Anna Kozlova
2024-04-29 21:00:24 +00:00
committed by intellij-monorepo-bot
parent 4cc5e5f9cb
commit 882dbec1fb
7 changed files with 48 additions and 1 deletions
@@ -1457,6 +1457,19 @@ public abstract class FindUsagesWithCompilerReferenceIndexFirTestGenerated exten
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../idea/tests/testData/findUsages/kotlin/findClassUsages")
public static class TestPrimaryConstructorOfEnum extends AbstractFindUsagesWithCompilerReferenceIndexFirTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("primaryConstructorOfEnum.0.kt")
public void testPrimaryConstructorOfEnum() throws Exception {
runTest("../../idea/tests/testData/findUsages/kotlin/findClassUsages/primaryConstructorOfEnum.0.kt");
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../idea/tests/testData/findUsages/kotlin/findClassUsages")
public static class TestPrimaryConstructorWithDefaultParams extends AbstractFindUsagesWithCompilerReferenceIndexFirTest {
@@ -1457,6 +1457,19 @@ public abstract class FindUsagesWithCompilerReferenceIndexTestGenerated extends
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../idea/tests/testData/findUsages/kotlin/findClassUsages")
public static class TestPrimaryConstructorOfEnum extends AbstractFindUsagesWithCompilerReferenceIndexTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("primaryConstructorOfEnum.0.kt")
public void testPrimaryConstructorOfEnum() throws Exception {
runTest("../../idea/tests/testData/findUsages/kotlin/findClassUsages/primaryConstructorOfEnum.0.kt");
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../idea/tests/testData/findUsages/kotlin/findClassUsages")
public static class TestPrimaryConstructorWithDefaultParams extends AbstractFindUsagesWithCompilerReferenceIndexTest {
@@ -609,6 +609,11 @@ public abstract class FindUsagesFirTestGenerated extends AbstractFindUsagesFirTe
runTest("../../idea/tests/testData/findUsages/kotlin/findClassUsages/localAndNonLocalClass.0.kt");
}
@TestMetadata("primaryConstructorOfEnum.0.kt")
public void testPrimaryConstructorOfEnum() throws Exception {
runTest("../../idea/tests/testData/findUsages/kotlin/findClassUsages/primaryConstructorOfEnum.0.kt");
}
@TestMetadata("primaryConstructorWithDefaultParams.0.kt")
public void testPrimaryConstructorWithDefaultParams() throws Exception {
runTest("../../idea/tests/testData/findUsages/kotlin/findClassUsages/primaryConstructorWithDefaultParams.0.kt");
@@ -609,6 +609,11 @@ public abstract class FindUsagesTestGenerated extends AbstractFindUsagesTest {
runTest("testData/findUsages/kotlin/findClassUsages/localAndNonLocalClass.0.kt");
}
@TestMetadata("primaryConstructorOfEnum.0.kt")
public void testPrimaryConstructorOfEnum() throws Exception {
runTest("testData/findUsages/kotlin/findClassUsages/primaryConstructorOfEnum.0.kt");
}
@TestMetadata("primaryConstructorWithDefaultParams.0.kt")
public void testPrimaryConstructorWithDefaultParams() throws Exception {
runTest("testData/findUsages/kotlin/findClassUsages/primaryConstructorWithDefaultParams.0.kt");
@@ -0,0 +1,7 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtClass
// OPTIONS: usages, constructorUsages
// PSI_ELEMENT_AS_TITLE: "class E"
enum class <caret>E(b: Boolean) {
A(false),
B(true)
}
@@ -87,7 +87,10 @@ class KotlinFindClassUsagesHandler(
addTask { ReferencesSearch.search(constructor, options.searchScope).forEach(referenceProcessor) }
addTask(
constructor.buildProcessDelegationCallKotlinConstructorUsagesTask(options.searchScope) { callElement ->
callElement.calleeExpression?.let { referenceProcessor.process(it.mainReference) } != false
callElement.calleeExpression?.let { callee ->
val reference = callee.mainReference
reference == null || referenceProcessor.process(reference)
} != false
}
)
}