Create ProhibitTypeParametersForLocalVariablesMigrationInspection
#KT-36261 Fixed
This commit is contained in:
@@ -3119,6 +3119,16 @@
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.migration.ProhibitTypeParametersForLocalVariablesMigrationInspection"
|
||||
displayName="Local variables are not allowed to have type parameters since 1.4"
|
||||
groupPath="Kotlin"
|
||||
groupName="Migration"
|
||||
enabledByDefault="false"
|
||||
cleanupTool="true"
|
||||
level="ERROR"
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.migration.ObsoleteExperimentalCoroutinesInspection"
|
||||
displayName="Experimental coroutines usages are deprecated since 1.3"
|
||||
groupPath="Kotlin"
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Since Kotlin 1.4, it's forbidden to declare a local variable with type parameters.
|
||||
</body>
|
||||
</html>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.inspections.migration
|
||||
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
|
||||
import org.jetbrains.kotlin.idea.configuration.isLanguageVersionUpdate
|
||||
import org.jetbrains.kotlin.idea.quickfix.migration.MigrationFix
|
||||
import org.jetbrains.kotlin.psi.KtTypeParameterList
|
||||
|
||||
|
||||
class ProhibitTypeParametersForLocalVariablesMigrationInspection :
|
||||
AbstractDiagnosticBasedMigrationInspection<KtTypeParameterList>(
|
||||
Errors.LOCAL_VARIABLE_WITH_TYPE_PARAMETERS,
|
||||
KtTypeParameterList::class.java,
|
||||
),
|
||||
MigrationFix,
|
||||
CleanupLocalInspectionTool {
|
||||
override fun isApplicable(migrationInfo: MigrationInfo): Boolean {
|
||||
return migrationInfo.isLanguageVersionUpdate(LanguageVersion.KOTLIN_1_3, LanguageVersion.KOTLIN_1_4)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.migration.ProhibitTypeParametersForLocalVariablesMigrationInspection
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// LANGUAGE_VERSION: 1.4
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val <T : __UNRESOLVED__><caret> x = ""
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// LANGUAGE_VERSION: 1.4
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val x = ""
|
||||
}
|
||||
+18
@@ -6603,6 +6603,24 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/prohibitTypeParametersForLocalVariablesMigration")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ProhibitTypeParametersForLocalVariablesMigration extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProhibitTypeParametersForLocalVariablesMigration() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/prohibitTypeParametersForLocalVariablesMigration"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/prohibitTypeParametersForLocalVariablesMigration/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/recursiveEqualsCall")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user