FIR IDE: Enable ChangeVariableMutabilityFix for MUST_BE_INITIALIZED.
This commit is contained in:
committed by
Ilya Kirillov
parent
09fb2cd746
commit
bb790195a2
@@ -1127,7 +1127,7 @@ fun main(args: Array<String>) {
|
||||
model("quickfix/lateinit", pattern = pattern, filenameStartsLowerCase = true)
|
||||
model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
|
||||
model("quickfix/override/typeMismatchOnOverride", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
|
||||
model("quickfix/variables/changeMutability", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
|
||||
model("quickfix/variables/changeMutability", pattern = pattern, filenameStartsLowerCase = true)
|
||||
}
|
||||
|
||||
testClass<AbstractHLInspectionTest> {
|
||||
|
||||
@@ -61,6 +61,7 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() {
|
||||
registerPsiQuickFixes(KtFirDiagnostic.VarAnnotationParameter::class, ChangeVariableMutabilityFix.VAR_ANNOTATION_PARAMETER_FACTORY)
|
||||
registerPsiQuickFixes(KtFirDiagnostic.InapplicableLateinitModifier::class, ChangeVariableMutabilityFix.LATEINIT_VAL_FACTORY)
|
||||
registerPsiQuickFixes(KtFirDiagnostic.ValWithSetter::class, ChangeVariableMutabilityFix.VAL_WITH_SETTER_FACTORY)
|
||||
registerPsiQuickFixes(KtFirDiagnostic.MustBeInitialized::class, ChangeVariableMutabilityFix.MUST_BE_INITIALIZED_FACTORY)
|
||||
}
|
||||
|
||||
override val list: KtQuickFixesList = KtQuickFixesList.createCombined(
|
||||
|
||||
+5
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInspection.InspectionProfileEntry
|
||||
import org.jetbrains.kotlin.test.uitls.IgnoreTests
|
||||
import java.nio.file.Paths
|
||||
|
||||
@@ -22,6 +23,10 @@ abstract class AbstractHighLevelQuickFixTest : AbstractQuickFixTest() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Enable these as more actions/inspections are enabled, and/or add more FIR-specific directives
|
||||
override fun checkForUnexpectedErrors() {}
|
||||
override fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {}
|
||||
override fun parseInspectionsToEnable(beforeFileName: String, beforeFileText: String): List<InspectionProfileEntry> {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
Generated
+59
-1
@@ -695,7 +695,7 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInChangeMutability() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/variables/changeMutability"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/variables/changeMutability"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("capturedMemberValInitialization.kt")
|
||||
@@ -762,5 +762,63 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
|
||||
public void testVarAnnotationParameter() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/variables/changeMutability/canBeVal")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CanBeVal extends AbstractHighLevelQuickFixTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCanBeVal() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/variables/changeMutability/canBeVal"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("const.kt")
|
||||
public void testConst() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/const.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedProperty.kt")
|
||||
public void testDelegatedProperty() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/delegatedProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedProperty2.kt")
|
||||
public void testDelegatedProperty2() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/delegatedProperty2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedProperty3.kt")
|
||||
public void testDelegatedProperty3() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/delegatedProperty3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multiVariable.kt")
|
||||
public void testMultiVariable() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/multiVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleVariable.kt")
|
||||
public void testSingleVariable() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/singleVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uninitializedWithGetter.kt")
|
||||
public void testUninitializedWithGetter() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/uninitializedWithGetter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uninitializedWithGetter2.kt")
|
||||
public void testUninitializedWithGetter2() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/uninitializedWithGetter2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uninitializedWithGetter3.kt")
|
||||
public void testUninitializedWithGetter3() throws Exception {
|
||||
runTest("idea/testData/quickfix/variables/changeMutability/canBeVal/uninitializedWithGetter3.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,4 +12,5 @@ fun test() {
|
||||
class Delegate {
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
+2
-1
@@ -10,4 +10,5 @@ fun test() {
|
||||
var foo: String by <caret>Delegate()
|
||||
}
|
||||
|
||||
class Delegate
|
||||
class Delegate
|
||||
/* FIR_COMPARISON */
|
||||
+2
-1
@@ -2,4 +2,5 @@
|
||||
class Test {
|
||||
var foo<caret>
|
||||
get() = 1
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
Vendored
+2
-1
@@ -2,4 +2,5 @@
|
||||
class Test {
|
||||
val foo
|
||||
get() = 1
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
+2
-1
@@ -4,4 +4,5 @@ class Test {
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
Vendored
+2
-1
@@ -4,4 +4,5 @@ class Test {
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
+2
-1
@@ -11,4 +11,5 @@ class Test {
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
/* FIR_COMPARISON */
|
||||
Reference in New Issue
Block a user