FIR IDE: add quick fix tests

This commit is contained in:
Ilya Kirillov
2021-02-02 22:05:27 +01:00
parent 5d32cb0daf
commit 9304056901
4 changed files with 364 additions and 2 deletions
@@ -116,6 +116,7 @@ import org.jetbrains.kotlin.idea.navigation.*
import org.jetbrains.kotlin.idea.navigationToolbar.AbstractKotlinNavBarTest
import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest
import org.jetbrains.kotlin.idea.perf.*
import org.jetbrains.kotlin.idea.quickfix.AbstractHighLevelQuickFixTest
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiModuleTest
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest
@@ -1100,6 +1101,12 @@ fun main(args: Array<String>) {
model("checker/infos")
model("checker/diagnosticsMessage")
}
testClass<AbstractHighLevelQuickFixTest> {
val pattern = "^([\\w\\-_]+)\\.kt$"
model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false)
}
}
testGroup("idea/idea-fir/tests", "idea/idea-completion/testData") {
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 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.quickfix
import com.intellij.codeInsight.intention.IntentionAction
abstract class AbstractHighLevelQuickFixTest : AbstractQuickFixTest() {
override fun checkForUnexpectedErrors() {}
override fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {}
}
@@ -0,0 +1,336 @@
/*
* Copyright 2010-2021 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.quickfix;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/quickfix/modifiers")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("abstractModifierInEnum.kt")
public void testAbstractModifierInEnum() throws Exception {
runTest("idea/testData/quickfix/modifiers/abstractModifierInEnum.kt");
}
@TestMetadata("addLateinit.kt")
public void testAddLateinit() throws Exception {
runTest("idea/testData/quickfix/modifiers/addLateinit.kt");
}
public void testAllFilesPresentInModifiers() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/modifiers"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, false);
}
@TestMetadata("cannotMakeClassAnnotation.kt")
public void testCannotMakeClassAnnotation() throws Exception {
runTest("idea/testData/quickfix/modifiers/cannotMakeClassAnnotation.kt");
}
@TestMetadata("finalTrait.kt")
public void testFinalTrait() throws Exception {
runTest("idea/testData/quickfix/modifiers/finalTrait.kt");
}
@TestMetadata("illegalEnumAnnotation1.kt")
public void testIllegalEnumAnnotation1() throws Exception {
runTest("idea/testData/quickfix/modifiers/illegalEnumAnnotation1.kt");
}
@TestMetadata("illegalEnumAnnotation2.kt")
public void testIllegalEnumAnnotation2() throws Exception {
runTest("idea/testData/quickfix/modifiers/illegalEnumAnnotation2.kt");
}
@TestMetadata("infixModifier.kt")
public void testInfixModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/infixModifier.kt");
}
@TestMetadata("kt10409.kt")
public void testKt10409() throws Exception {
runTest("idea/testData/quickfix/modifiers/kt10409.kt");
}
@TestMetadata("nestedAbstractClass.kt")
public void testNestedAbstractClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedAbstractClass.kt");
}
@TestMetadata("nestedAnnotationClass.kt")
public void testNestedAnnotationClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedAnnotationClass.kt");
}
@TestMetadata("nestedClassNotAllowed.kt")
public void testNestedClassNotAllowed() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedClassNotAllowed.kt");
}
@TestMetadata("nestedDataClass.kt")
public void testNestedDataClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedDataClass.kt");
}
@TestMetadata("nestedEnumClass.kt")
public void testNestedEnumClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedEnumClass.kt");
}
@TestMetadata("nestedInterface.kt")
public void testNestedInterface() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedInterface.kt");
}
@TestMetadata("nestedObject.kt")
public void testNestedObject() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedObject.kt");
}
@TestMetadata("nestedSealedClass.kt")
public void testNestedSealedClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/nestedSealedClass.kt");
}
@TestMetadata("noAbstractForAnonymousObject.kt")
public void testNoAbstractForAnonymousObject() throws Exception {
runTest("idea/testData/quickfix/modifiers/noAbstractForAnonymousObject.kt");
}
@TestMetadata("noAbstractForObject.kt")
public void testNoAbstractForObject() throws Exception {
runTest("idea/testData/quickfix/modifiers/noAbstractForObject.kt");
}
@TestMetadata("noLateinitOnNullable.kt")
public void testNoLateinitOnNullable() throws Exception {
runTest("idea/testData/quickfix/modifiers/noLateinitOnNullable.kt");
}
@TestMetadata("noLateinitOnPrimitive.kt")
public void testNoLateinitOnPrimitive() throws Exception {
runTest("idea/testData/quickfix/modifiers/noLateinitOnPrimitive.kt");
}
@TestMetadata("notAnAnnotationClass.kt")
public void testNotAnAnnotationClass() throws Exception {
runTest("idea/testData/quickfix/modifiers/notAnAnnotationClass.kt");
}
@TestMetadata("openCompanionObject.kt")
public void testOpenCompanionObject() throws Exception {
runTest("idea/testData/quickfix/modifiers/openCompanionObject.kt");
}
@TestMetadata("openCompanionObject2.kt")
public void testOpenCompanionObject2() throws Exception {
runTest("idea/testData/quickfix/modifiers/openCompanionObject2.kt");
}
@TestMetadata("openMemberInFinalClass1.kt")
public void testOpenMemberInFinalClass1() throws Exception {
runTest("idea/testData/quickfix/modifiers/openMemberInFinalClass1.kt");
}
@TestMetadata("openMemberInFinalClass2.kt")
public void testOpenMemberInFinalClass2() throws Exception {
runTest("idea/testData/quickfix/modifiers/openMemberInFinalClass2.kt");
}
@TestMetadata("openMemberInFinalClass3.kt")
public void testOpenMemberInFinalClass3() throws Exception {
runTest("idea/testData/quickfix/modifiers/openMemberInFinalClass3.kt");
}
@TestMetadata("openMemberInFinalClass4.kt")
public void testOpenMemberInFinalClass4() throws Exception {
runTest("idea/testData/quickfix/modifiers/openMemberInFinalClass4.kt");
}
@TestMetadata("openModifierInEnum.kt")
public void testOpenModifierInEnum() throws Exception {
runTest("idea/testData/quickfix/modifiers/openModifierInEnum.kt");
}
@TestMetadata("openObject.kt")
public void testOpenObject() throws Exception {
runTest("idea/testData/quickfix/modifiers/openObject.kt");
}
@TestMetadata("openVarWithPrivateSetter.kt")
public void testOpenVarWithPrivateSetter() throws Exception {
runTest("idea/testData/quickfix/modifiers/openVarWithPrivateSetter.kt");
}
@TestMetadata("operatorModifier.kt")
public void testOperatorModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/operatorModifier.kt");
}
@TestMetadata("operatorModifierCollection.kt")
public void testOperatorModifierCollection() throws Exception {
runTest("idea/testData/quickfix/modifiers/operatorModifierCollection.kt");
}
@TestMetadata("operatorModifierComponent.kt")
public void testOperatorModifierComponent() throws Exception {
runTest("idea/testData/quickfix/modifiers/operatorModifierComponent.kt");
}
@TestMetadata("operatorModifierGet.kt")
public void testOperatorModifierGet() throws Exception {
runTest("idea/testData/quickfix/modifiers/operatorModifierGet.kt");
}
@TestMetadata("operatorModifierInherited.kt")
public void testOperatorModifierInherited() throws Exception {
runTest("idea/testData/quickfix/modifiers/operatorModifierInherited.kt");
}
@TestMetadata("overrideWithPrivateSetter.kt")
public void testOverrideWithPrivateSetter() throws Exception {
runTest("idea/testData/quickfix/modifiers/overrideWithPrivateSetter.kt");
}
@TestMetadata("packageMemberCannotBeProtected.kt")
public void testPackageMemberCannotBeProtected() throws Exception {
runTest("idea/testData/quickfix/modifiers/packageMemberCannotBeProtected.kt");
}
@TestMetadata("redundantOpenInInterface.kt")
public void testRedundantOpenInInterface() throws Exception {
runTest("idea/testData/quickfix/modifiers/redundantOpenInInterface.kt");
}
@TestMetadata("removeAbstractModifier.kt")
public void testRemoveAbstractModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeAbstractModifier.kt");
}
@TestMetadata("removeConst.kt")
public void testRemoveConst() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeConst.kt");
}
@TestMetadata("removeIncompatibleModifier.kt")
public void testRemoveIncompatibleModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
}
@TestMetadata("removeInnerForClassInTrait.kt")
public void testRemoveInnerForClassInTrait() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeInnerForClassInTrait.kt");
}
@TestMetadata("removeModifierFromForbiddenOperatorMod.kt")
public void testRemoveModifierFromForbiddenOperatorMod() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeModifierFromForbiddenOperatorMod.kt");
}
@TestMetadata("removeModifierFromOperatorMod.kt")
public void testRemoveModifierFromOperatorMod() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeModifierFromOperatorMod.kt");
}
@TestMetadata("removeModifierFromOperatorModAssign.kt")
public void testRemoveModifierFromOperatorModAssign() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeModifierFromOperatorModAssign.kt");
}
@TestMetadata("removeProtectedModifier.kt")
public void testRemoveProtectedModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeProtectedModifier.kt");
}
@TestMetadata("removeRedundantModifier1.kt")
public void testRemoveRedundantModifier1() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeRedundantModifier1.kt");
}
@TestMetadata("removeRedundantModifier2.kt")
public void testRemoveRedundantModifier2() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeRedundantModifier2.kt");
}
@TestMetadata("removeRedundantModifier3.kt")
public void testRemoveRedundantModifier3() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeRedundantModifier3.kt");
}
@TestMetadata("removeSupertype1.kt")
public void testRemoveSupertype1() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeSupertype1.kt");
}
@TestMetadata("removeSupertype2.kt")
public void testRemoveSupertype2() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeSupertype2.kt");
}
@TestMetadata("removeSupertype3.kt")
public void testRemoveSupertype3() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeSupertype3.kt");
}
@TestMetadata("removeSupertype4.kt")
public void testRemoveSupertype4() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeSupertype4.kt");
}
@TestMetadata("visibilityModifer1.kt")
public void testVisibilityModifer1() throws Exception {
runTest("idea/testData/quickfix/modifiers/visibilityModifer1.kt");
}
@TestMetadata("visibilityModifer2.kt")
public void testVisibilityModifer2() throws Exception {
runTest("idea/testData/quickfix/modifiers/visibilityModifer2.kt");
}
@TestMetadata("visibilityModiferOverrideJavaRuntime.kt")
public void testVisibilityModiferOverrideJavaRuntime() throws Exception {
runTest("idea/testData/quickfix/modifiers/visibilityModiferOverrideJavaRuntime.kt");
}
@TestMetadata("visibilityModiferParameter.kt")
public void testVisibilityModiferParameter() throws Exception {
runTest("idea/testData/quickfix/modifiers/visibilityModiferParameter.kt");
}
@TestMetadata("withAnnotationAndBlockComment.kt")
public void testWithAnnotationAndBlockComment() throws Exception {
runTest("idea/testData/quickfix/modifiers/withAnnotationAndBlockComment.kt");
}
@TestMetadata("withAnnotationAndEolComment.kt")
public void testWithAnnotationAndEolComment() throws Exception {
runTest("idea/testData/quickfix/modifiers/withAnnotationAndEolComment.kt");
}
@TestMetadata("withAnnotationAndEolComment2.kt")
public void testWithAnnotationAndEolComment2() throws Exception {
runTest("idea/testData/quickfix/modifiers/withAnnotationAndEolComment2.kt");
}
@TestMetadata("withAnnotationAndEolComment3.kt")
public void testWithAnnotationAndEolComment3() throws Exception {
runTest("idea/testData/quickfix/modifiers/withAnnotationAndEolComment3.kt");
}
}
@@ -20,6 +20,7 @@ import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.ui.UIUtil
import junit.framework.TestCase
import org.jetbrains.annotations.NotNull
import org.jetbrains.kotlin.idea.caches.resolve.ResolveInDispatchThreadException
import org.jetbrains.kotlin.idea.caches.resolve.forceCheckForResolveInDispatchThreadInTests
import org.jetbrains.kotlin.idea.facet.KotlinFacet
@@ -231,7 +232,7 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
}
} else {
// Action shouldn't be found. Check that other actions are expected and thus tested action isn't there under another name.
DirectiveBasedActionUtils.checkAvailableActionsAreExpected(myFixture.file, actions)
checkAvailableActionsAreExpected(actions)
}
}
}
@@ -259,7 +260,11 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
return null
}
private fun checkForUnexpectedErrors() = DirectiveBasedActionUtils.checkForUnexpectedErrors(myFixture.file as KtFile)
protected open fun checkAvailableActionsAreExpected(actions: List<IntentionAction>) {
DirectiveBasedActionUtils.checkAvailableActionsAreExpected(myFixture.file, actions)
}
protected open fun checkForUnexpectedErrors() = DirectiveBasedActionUtils.checkForUnexpectedErrors(myFixture.file as KtFile)
override fun getTestDataPath(): String {
// Ensure full path is returned. Otherwise FileComparisonFailureException does not provide link to file diff