diff --git a/idea/resources/inspectionDescriptions/RemoveExplicitTypeArgs.html b/idea/resources/inspectionDescriptions/RemoveExplicitTypeArgs.html new file mode 100644 index 0000000000000..869aea11393bf --- /dev/null +++ b/idea/resources/inspectionDescriptions/RemoveExplicitTypeArgs.html @@ -0,0 +1,5 @@ + + +This inspection reports any function call wiith type arguments that can be safely removed and inferred + + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 850f7b2eb7def..633746d141773 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -655,7 +655,6 @@ org.jetbrains.jet.plugin.intentions.SimplifyBooleanWithConstantsIntention Kotlin - org.jetbrains.jet.plugin.intentions.SwapBinaryExpression @@ -718,6 +717,13 @@ level="WARNING" /> + + diff --git a/idea/src/org/jetbrains/jet/plugin/inspections/RemoveExplicitTypeArgsInspection.kt b/idea/src/org/jetbrains/jet/plugin/inspections/RemoveExplicitTypeArgsInspection.kt new file mode 100644 index 0000000000000..3b2daffa5c25d --- /dev/null +++ b/idea/src/org/jetbrains/jet/plugin/inspections/RemoveExplicitTypeArgsInspection.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.inspections + +import org.jetbrains.jet.plugin.intentions.RemoveExplicitTypeArguments +import org.jetbrains.jet.lang.psi.JetCallExpression + +public class RemoveExplicitTypeArgsInspection : IntentionBasedInspection(RemoveExplicitTypeArguments()) diff --git a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml new file mode 100644 index 0000000000000..4d264d64d7289 --- /dev/null +++ b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/expected.xml @@ -0,0 +1,101 @@ + + + variableStringFartherScope.kt + 5 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + fourLiterals.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + literalStringWithClass.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + lambdaType.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + literalAny.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + literalString.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + variablesAndLiterals.kt + 5 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + literalsWhenTypeArgHasTypeArg.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + variableString.kt + 4 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + variableString2.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + + twoLiteralValues.kt + 3 + light_idea_test_case + + Type arguments are unnecessary + Remove explicit type arguments + + + \ No newline at end of file diff --git a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test new file mode 100644 index 0000000000000..d174e685ea578 --- /dev/null +++ b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test @@ -0,0 +1 @@ +// INSPECTION_CLASS: org.jetbrains.jet.plugin.inspections.RemoveExplicitTypeArgsInspection \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/JetInspectionTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/JetInspectionTestGenerated.java index f19fe9767518f..a7fd869493769 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/JetInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/JetInspectionTestGenerated.java @@ -51,4 +51,9 @@ public void testBranched_ifThenToSafeAccess_inspectionData_Inspections_test() th doTest("idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test"); } + @TestMetadata("removeExplicitTypeArguments/inspectionData/inspections.test") + public void testRemoveExplicitTypeArguments_inspectionData_Inspections_test() throws Exception { + doTest("idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test"); + } + } diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java index 4aa336609be68..74ba43ff25f7f 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/CodeTransformationTestGenerated.java @@ -7,6 +7,7 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -3719,6 +3720,7 @@ public void testSimpleInsertTypeFun() throws Exception { } @TestMetadata("idea/testData/intentions/removeExplicitTypeArguments") + @InnerTestClasses({}) public static class RemoveExplicitTypeArguments extends AbstractCodeTransformationTest { public void testAllFilesPresentInRemoveExplicitTypeArguments() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/removeExplicitTypeArguments"), Pattern.compile("^(.+)\\.kt$"), true); @@ -3799,6 +3801,11 @@ public void testVariablesAndLiterals() throws Exception { doTestRemoveExplicitTypeArguments("idea/testData/intentions/removeExplicitTypeArguments/variablesAndLiterals.kt"); } + public static Test innerSuite() { + TestSuite suite = new TestSuite("RemoveExplicitTypeArguments"); + suite.addTestSuite(RemoveExplicitTypeArguments.class); + return suite; + } } @TestMetadata("idea/testData/intentions/convertAssertToIf") @@ -4171,7 +4178,7 @@ public static Test suite() { suite.addTestSuite(ReplaceWithTraditionalAssignment.class); suite.addTestSuite(SimplifyBooleanWithConstants.class); suite.addTestSuite(InsertExplicitTypeArguments.class); - suite.addTestSuite(RemoveExplicitTypeArguments.class); + suite.addTest(RemoveExplicitTypeArguments.innerSuite()); suite.addTestSuite(ConvertAssertToIf.class); suite.addTestSuite(ConvertIfToAssert.class); suite.addTestSuite(MakeTypeExplicitInLambda.class);