[kotlin] CreateLabelFix K2: Use /* IGNORE_K2 */ for quickfix test data, generate K2 tests but ignore them, formatting

KTIJ-29594

GitOrigin-RevId: 86de0c3883bbfb144ade3b7aedcc695e5af60b61
This commit is contained in:
Victoria.Petrakovich
2024-08-07 11:40:57 +00:00
committed by intellij-monorepo-bot
parent ff0f2d4bf6
commit 955c753eae
15 changed files with 108 additions and 14 deletions
@@ -15,15 +15,19 @@ internal object CreateLabelFixFactory {
val labelReferenceExpression = diagnostic.psi as? KtLabelReferenceExpression ?: return@IntentionBased emptyList()
val fixes = when ((labelReferenceExpression.parent as? KtContainerNode)?.parent) {
is KtBreakExpression, is KtContinueExpression -> {
if (labelReferenceExpression.getContainingLoops()
.any()
) listOf(CreateLabelFix.ForLoop(labelReferenceExpression)) else emptyList()
if (labelReferenceExpression.getContainingLoops().any()) {
listOf(CreateLabelFix.ForLoop(labelReferenceExpression))
} else {
emptyList()
}
}
is KtReturnExpression -> {
if (labelReferenceExpression.getContainingLambdas()
.any()
) listOf(CreateLabelFix.ForLambda(labelReferenceExpression)) else emptyList()
if (labelReferenceExpression.getContainingLambdas().any()) {
listOf(CreateLabelFix.ForLambda(labelReferenceExpression))
} else {
emptyList()
}
}
else -> emptyList()
@@ -7122,7 +7122,64 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../../idea/tests/testData/quickfix/createLabel")
public static class CreateLabel extends AbstractHighLevelQuickFixTest {
@java.lang.Override
@org.jetbrains.annotations.NotNull
public final KotlinPluginMode getPluginMode() {
return KotlinPluginMode.K2;
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("breakInLoop.kt")
public void testBreakInLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/breakInLoop.kt");
}
@TestMetadata("breakInOuterLoop.kt")
public void testBreakInOuterLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/breakInOuterLoop.kt");
}
@TestMetadata("breakInlambdaBeforeLoop.kt")
public void testBreakInlambdaBeforeLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/breakInlambdaBeforeLoop.kt");
}
@TestMetadata("breakNoLoop.kt")
public void testBreakNoLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/breakNoLoop.kt");
}
@TestMetadata("continueInLoop.kt")
public void testContinueInLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/continueInLoop.kt");
}
@TestMetadata("continueNoLoop.kt")
public void testContinueNoLoop() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/continueNoLoop.kt");
}
@TestMetadata("returnInLambda.kt")
public void testReturnInLambda() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/returnInLambda.kt");
}
@TestMetadata("returnInOuterLambda.kt")
public void testReturnInOuterLambda() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/returnInOuterLambda.kt");
}
@TestMetadata("returnNoLambda.kt")
public void testReturnNoLambda() throws Exception {
runTest("../../../idea/tests/testData/quickfix/createLabel/returnNoLambda.kt");
}
}
@@ -14,11 +14,19 @@ internal object CreateLabelFixFactory : KotlinSingleIntentionActionFactory() {
val labelReferenceExpression = diagnostic.psiElement as? KtLabelReferenceExpression ?: return null
return when ((labelReferenceExpression.parent as? KtContainerNode)?.parent) {
is KtBreakExpression, is KtContinueExpression -> {
if (labelReferenceExpression.getContainingLoops().any()) CreateLabelFix.ForLoop(labelReferenceExpression) else null
if (labelReferenceExpression.getContainingLoops().any()) {
CreateLabelFix.ForLoop(labelReferenceExpression)
} else {
null
}
}
is KtReturnExpression -> {
if (labelReferenceExpression.getContainingLambdas().any()) CreateLabelFix.ForLambda(labelReferenceExpression) else null
if (labelReferenceExpression.getContainingLambdas().any()) {
CreateLabelFix.ForLambda(labelReferenceExpression)
} else {
null
}
}
else -> null
@@ -1,4 +1,6 @@
// IGNORE_K2
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,4 +1,6 @@
// IGNORE_K2
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,4 +1,6 @@
// IGNORE_K2
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,4 +1,6 @@
// IGNORE_K2
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,4 +1,3 @@
// IGNORE_K2
// "Create label foo@" "false"
// ERROR: The label '@foo' does not denote a loop
// ERROR: Unresolved reference: @foo
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
fun test() {
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
@@ -1,3 +1,6 @@
/* IGNORE_K2 */
// Remove this ignoring after KT-69829 is fixed
// "Create label foo@" "true"
inline fun Int.bar(f: (Int) -> Unit) { }
@@ -110,7 +110,7 @@ internal fun MutableTWorkspace.generateK2FixTests() {
model("$idea/quickfix/convertToAnonymousObject", pattern = pattern, isIgnored = true)
model("$idea/quickfix/convertToIsArrayOfCall", pattern = pattern)
model("$idea/quickfix/createFromUsage", pattern = pattern, isIgnored = true)
model("$idea/quickfix/createLabel", pattern = pattern, isIgnored = true) // Remove `isIgnored` after KT-69829 is fixed
model("$idea/quickfix/createLabel", pattern = pattern)
model("$idea/quickfix/declarationCantBeInlined", pattern = pattern, isIgnored = true)
model("$idea/quickfix/declaringJavaClass", pattern = pattern, isIgnored = true)
model("$idea/quickfix/decreaseVisibility", pattern = pattern)