[kotlin] Port ConvertStringToCharLiteralFix to K2

^KTIJ-29624

GitOrigin-RevId: c6a20b852b88c9e21106d45f8832423373ec3557
This commit is contained in:
Andrey Cherkasov
2024-06-14 00:32:36 +00:00
committed by intellij-monorepo-bot
parent 5ee5610922
commit 07e4774d29
36 changed files with 266 additions and 30 deletions
@@ -0,0 +1,75 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.k2.codeinsight.fixes
import com.intellij.modcommand.ActionContext
import com.intellij.modcommand.ModPsiUpdater
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.analysis.api.KaSession
import org.jetbrains.kotlin.analysis.api.components.KaConstantEvaluationMode
import org.jetbrains.kotlin.analysis.api.fir.diagnostics.KaFirDiagnostic
import org.jetbrains.kotlin.analysis.api.types.KaType
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
import org.jetbrains.kotlin.idea.codeinsight.api.applicable.intentions.KotlinPsiUpdateModCommandAction
import org.jetbrains.kotlin.idea.codeinsight.api.applicators.fixes.KotlinQuickFixFactory
import org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralUtils
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
internal object ConvertStringToCharLiteralFixFactory {
val argumentTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ArgumentTypeMismatch ->
getFixes(diagnostic.psi, diagnostic.expectedType)
}
val assignmentTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.AssignmentTypeMismatch ->
getFixes(diagnostic.psi, diagnostic.expectedType)
}
val equalityNotApplicableFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.EqualityNotApplicable ->
val element = diagnostic.psi
getFixes(element.left, diagnostic.rightType).takeUnless { it.isEmpty() } ?: getFixes(element.right, diagnostic.leftType)
}
val incompatibleTypesFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.IncompatibleTypes ->
getFixes(diagnostic.psi, diagnostic.typeA)
}
val initializerTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.InitializerTypeMismatch ->
getFixes((diagnostic.psi as? KtProperty)?.initializer, diagnostic.expectedType)
}
val returnTypeMismatchFactory = KotlinQuickFixFactory.ModCommandBased { diagnostic: KaFirDiagnostic.ReturnTypeMismatch ->
getFixes(diagnostic.psi, diagnostic.expectedType)
}
context(KaSession)
private fun getFixes(element: PsiElement?, expectedType: KaType): List<ConvertStringToCharLiteralFix> {
if (element !is KtStringTemplateExpression) return emptyList()
if (!expectedType.isChar) return emptyList()
val charLiteral = ConvertStringToCharLiteralUtils.prepareCharLiteral(element) ?: return emptyList()
if (charLiteral.evaluate(KaConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION) == null) return emptyList()
return listOf(
ConvertStringToCharLiteralFix(element, charLiteral)
)
}
private class ConvertStringToCharLiteralFix(
element: KtStringTemplateExpression,
private val charLiteral: KtExpression, // No need for `SmartPsiElementPointer` since the expression is created by `KtPsiFactory`
) : KotlinPsiUpdateModCommandAction.ElementBased<KtStringTemplateExpression, Unit>(element, Unit) {
override fun getFamilyName() = KotlinBundle.message("convert.string.to.character.literal")
override fun invoke(
actionContext: ActionContext,
element: KtStringTemplateExpression,
elementContext: Unit,
updater: ModPsiUpdater,
) {
element.replace(charLiteral)
}
}
}
@@ -145,6 +145,15 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
registerFactory(ChangeToLabeledReturnFixFactory.returnTypeMismatch)
}
private val convertStringToCharLiteral = KtQuickFixesListBuilder.registerPsiQuickFix {
registerFactory(ConvertStringToCharLiteralFixFactory.argumentTypeMismatchFactory)
registerFactory(ConvertStringToCharLiteralFixFactory.assignmentTypeMismatchFactory)
registerFactory(ConvertStringToCharLiteralFixFactory.equalityNotApplicableFactory)
registerFactory(ConvertStringToCharLiteralFixFactory.incompatibleTypesFactory)
registerFactory(ConvertStringToCharLiteralFixFactory.initializerTypeMismatchFactory)
registerFactory(ConvertStringToCharLiteralFixFactory.returnTypeMismatchFactory)
}
private val insertDelegationCall = KtQuickFixesListBuilder.registerPsiQuickFix {
registerFactory(InsertDelegationCallFixFactory.primaryConstructorDelegationCallExpected)
registerFactory(InsertDelegationCallFixFactory.explicitDelegationCallRequiredSuper)
@@ -407,6 +416,7 @@ class KotlinK2QuickFixRegistrar : KotlinQuickFixRegistrar() {
addFinal,
addInline,
changeToLabeledReturn,
convertStringToCharLiteral,
insertDelegationCall,
propertyInitialization,
overrides,
@@ -3797,6 +3797,55 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes")
public static class IncompatibleTypes 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("byte.kt")
public void testByte() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/byte.kt");
}
@TestMetadata("changeReturnType.kt")
public void testChangeReturnType() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/changeReturnType.kt");
}
@TestMetadata("char.kt")
public void testChar() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char.kt");
}
@TestMetadata("char2.kt")
public void testChar2() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/char2.kt");
}
@TestMetadata("int.kt")
public void testInt() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/int.kt");
}
@TestMetadata("toString.kt")
public void testToString() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/toString.kt");
}
@TestMetadata("wrapWithCollectionLiteral.kt")
public void testWrapWithCollectionLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/incompatibleTypes/wrapWithCollectionLiteral.kt");
}
}
@RunWith(JUnit3RunnerWithInners.class)
@TestMetadata("../../../idea/tests/testData/quickfix/typeMismatch/numberConversion")
public abstract static class NumberConversion extends AbstractHighLevelQuickFixTest {
@@ -4079,6 +4128,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changePrimaryConstructorParameterTypeOnPropertyDelegate.kt");
}
@TestMetadata("char.kt")
public void testChar() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt");
}
@TestMetadata("convertKClassToJavaClass.kt")
public void testConvertKClassToJavaClass() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/convertKClassToJavaClass.kt");
@@ -4484,6 +4538,11 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
runTest("../../../idea/tests/testData/quickfix/typeMismatch/anyInReturn.kt");
}
@TestMetadata("cannotConvertStringToCharLiteral.kt")
public void testCannotConvertStringToCharLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt");
}
@TestMetadata("changeFunctionLiteralParameterTypeToFunctionType.kt")
public void testChangeFunctionLiteralParameterTypeToFunctionType() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/changeFunctionLiteralParameterTypeToFunctionType.kt");
@@ -4564,9 +4623,19 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu
runTest("../../../idea/tests/testData/quickfix/typeMismatch/constantTypeMismatch.kt");
}
@TestMetadata("convertStringToCharLiteral.kt")
public void testConvertStringToCharLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertStringToCharLiteral.kt");
@TestMetadata("convertAssignedStringToCharLiteral.kt")
public void testConvertAssignedStringToCharLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt");
}
@TestMetadata("convertReturnStringToCharLiteral.kt")
public void testConvertReturnStringToCharLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt");
}
@TestMetadata("convertStringInitializerToCharLiteral.kt")
public void testConvertStringInitializerToCharLiteral() throws Exception {
runTest("../../../idea/tests/testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt");
}
@TestMetadata("dontChangeOverriddenPropertyTypeToErrorType.kt")
@@ -18136,6 +18136,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changePrimaryConstructorParameterTypeOnPropertyDelegate.kt");
}
@TestMetadata("char.kt")
public void testChar() throws Exception {
runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/char.kt");
}
@TestMetadata("convertKClassToJavaClass.kt")
public void testConvertKClassToJavaClass() throws Exception {
runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/convertKClassToJavaClass.kt");
@@ -18501,6 +18506,11 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
runTest("testData/quickfix/typeMismatch/anyInReturn.kt");
}
@TestMetadata("cannotConvertStringToCharLiteral.kt")
public void testCannotConvertStringToCharLiteral() throws Exception {
runTest("testData/quickfix/typeMismatch/cannotConvertStringToCharLiteral.kt");
}
@TestMetadata("changeFunctionLiteralParameterTypeToFunctionType.kt")
public void testChangeFunctionLiteralParameterTypeToFunctionType() throws Exception {
runTest("testData/quickfix/typeMismatch/changeFunctionLiteralParameterTypeToFunctionType.kt");
@@ -18581,9 +18591,19 @@ public abstract class K1QuickFixTestGenerated extends AbstractK1QuickFixTest {
runTest("testData/quickfix/typeMismatch/constantTypeMismatch.kt");
}
@TestMetadata("convertStringToCharLiteral.kt")
public void testConvertStringToCharLiteral() throws Exception {
runTest("testData/quickfix/typeMismatch/convertStringToCharLiteral.kt");
@TestMetadata("convertAssignedStringToCharLiteral.kt")
public void testConvertAssignedStringToCharLiteral() throws Exception {
runTest("testData/quickfix/typeMismatch/convertAssignedStringToCharLiteral.kt");
}
@TestMetadata("convertReturnStringToCharLiteral.kt")
public void testConvertReturnStringToCharLiteral() throws Exception {
runTest("testData/quickfix/typeMismatch/convertReturnStringToCharLiteral.kt");
}
@TestMetadata("convertStringInitializerToCharLiteral.kt")
public void testConvertStringInitializerToCharLiteral() throws Exception {
runTest("testData/quickfix/typeMismatch/convertStringInitializerToCharLiteral.kt");
}
@TestMetadata("dontChangeOverriddenPropertyTypeToErrorType.kt")
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>c == "a"
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return c == 'a'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>"\t" == c
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return '\t' == c
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>c == """a"""
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return c == 'a'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>c == "\""
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>c == '"'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return <caret>c == "'"
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun test(c: Char): Boolean {
return c == '\''
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -0,0 +1,5 @@
// "Convert string to character literal" "false"
// ERROR: Type mismatch: inferred type is String but Int was expected
fun bar(): Int {
return <caret>"a"
}
@@ -0,0 +1,8 @@
// "Convert string to character literal" "true"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
fun bar(): Char {
val c: Char
c = "."<caret>
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -0,0 +1,8 @@
// "Convert string to character literal" "true"
// ERROR: A 'return' expression required in a function with a block body ('{...}')
fun bar(): Char {
val c: Char
c = '.'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun bar(): Char {
return <caret>"a"
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -3,4 +3,4 @@ fun bar(): Char {
return <caret>'a'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
/* IGNORE_K2 */
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -0,0 +1,6 @@
// "Convert string to character literal" "true"
fun foo() {
val c: Char = "."<caret>
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -0,0 +1,6 @@
// "Convert string to character literal" "true"
fun foo() {
val c: Char = '.'
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) {
<caret>i -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
/* IGNORE_K2 */
@@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) {
i.toByte() -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
/* IGNORE_K2 */
@@ -7,4 +7,5 @@ fun test(i: Int) {
}
fun foo(): String = TODO()
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled
/* IGNORE_K2 */
@@ -7,4 +7,5 @@ fun test(i: Int) {
}
fun foo(): Int = TODO()
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ChangeCallableReturnTypeFix$ForCalled
/* IGNORE_K2 */
@@ -4,4 +4,5 @@ fun test(c: Char) {
<caret>"." -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -4,4 +4,5 @@ fun test(c: Char) {
'.' -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) {
<caret>b -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
/* IGNORE_K2 */
@@ -4,4 +4,5 @@ fun test(b: Byte, i: Int) {
b.toInt() -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.NumberConversionFix
/* IGNORE_K2 */
@@ -4,4 +4,5 @@ fun test(s: String, i: Int) {
<caret>i -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix
/* IGNORE_K2 */
@@ -4,4 +4,5 @@ fun test(s: String, i: Int) {
i.toString() -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddToStringFix
/* IGNORE_K2 */
@@ -5,4 +5,5 @@ fun test(ints: List<Int>, i: Int) {
<caret>i -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix
/* IGNORE_K2 */
@@ -5,4 +5,5 @@ fun test(ints: List<Int>, i: Int) {
listOf(i) -> {}
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.WrapWithCollectionLiteralCallFix
/* IGNORE_K2 */
@@ -0,0 +1,8 @@
// "Convert string to character literal" "true"
fun foo(x: Char) {}
fun bar() {
foo("."<caret>)
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -0,0 +1,8 @@
// "Convert string to character literal" "true"
fun foo(x: Char) {}
fun bar() {
foo('.')
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ConvertStringToCharLiteralFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.k2.codeinsight.fixes.ConvertStringToCharLiteralFixFactory$ConvertStringToCharLiteralFix
@@ -46,6 +46,7 @@ internal fun MutableTWorkspace.generateK2FixTests() {
model("$idea/quickfix/typeAddition", pattern = pattern)
model("$idea/quickfix/typeMismatch/casts", pattern = pattern)
model("$idea/quickfix/typeMismatch/componentFunctionReturnTypeMismatch", pattern = pattern)
model("$idea/quickfix/typeMismatch/incompatibleTypes", pattern = pattern)
model("$idea/quickfix/typeMismatch/numberConversion", pattern = pattern)
model("$idea/quickfix/typeMismatch/parameterTypeMismatch", pattern = pattern)
model("$idea/quickfix/typeMismatch/typeMismatchOnReturnedExpression", pattern = pattern)