diff --git a/idea/resources/inspectionDescriptions/ReplaceToWithInfixFormInspection.html b/idea/resources/inspectionDescriptions/ReplaceToWithInfixFormInspection.html new file mode 100644 index 00000000000..5da45b35307 --- /dev/null +++ b/idea/resources/inspectionDescriptions/ReplaceToWithInfixFormInspection.html @@ -0,0 +1,5 @@ + + +This inspection reports to function calls replaceable with the infix form + + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index d34be2d324e..9051626d0eb 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -2683,6 +2683,15 @@ language="kotlin" /> + + - - + to(b) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceToWithInfixForm/base.kt.after b/idea/testData/inspectionsLocal/replaceToWithInfixForm/base.kt.after new file mode 100644 index 00000000000..499c40d4051 --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceToWithInfixForm/base.kt.after @@ -0,0 +1,7 @@ +// WITH_RUNTIME +class A +class B + +fun foo(a: A, b: B) { + val pair = a to b +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceToWithInfixForm/nonPair.kt b/idea/testData/inspectionsLocal/replaceToWithInfixForm/nonPair.kt new file mode 100644 index 00000000000..04591f42c1f --- /dev/null +++ b/idea/testData/inspectionsLocal/replaceToWithInfixForm/nonPair.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +class A { + fun to(x: Int) { + } +} + +fun foo() { + A().to(1) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 7347a7c79c7..9072ec61861 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -2463,6 +2463,27 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/replaceToWithInfixForm") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceToWithInfixForm extends AbstractLocalInspectionTest { + public void testAllFilesPresentInReplaceToWithInfixForm() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/replaceToWithInfixForm"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("base.kt") + public void testBase() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/replaceToWithInfixForm/base.kt"); + doTest(fileName); + } + + @TestMetadata("nonPair.kt") + public void testNonPair() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/replaceToWithInfixForm/nonPair.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/inspectionsLocal/selfAssignment") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)