diff --git a/Changelog.md b/Changelog.md index 08d132deb3d..52665b2752e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -103,7 +103,6 @@ New features: - Kotlin Education Plugin (for IDEA 2016) - [KT-9752](https://youtrack.jetbrains.com/issue/KT-9752) More usable file chooser for "Move declaration to another file" - [KT-9697](https://youtrack.jetbrains.com/issue/KT-9697) Move method to companion object and back -- [KT-11098](https://youtrack.jetbrains.com/issue/KT-11098) Inspection on final classes/functions annotated with Spring @Configuration/@Component/@Bean General issues fixed: diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 355216eb65b..cdd0372a9f1 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -779,13 +779,7 @@ fun main(args: Array) { } testGroup("idea/idea-ultimate/tests", "idea/testData") { - testClass("UltimateInspectionTestGenerated") { - model("ultimateInspections", pattern = "^(inspections\\.test)$", singleClass = true) - } - testClass("UltimateQuickFixTestGenerated") { - model("ultimateQuickFixes", pattern = "^([\\w\\-_]+)\\.kt$", filenameStartsLowerCase = true) - } } testGroup("idea/tests", "compiler/testData") { diff --git a/idea/idea-ultimate/idea-ultimate.iml b/idea/idea-ultimate/idea-ultimate.iml index 9626bf90871..1239656565e 100644 --- a/idea/idea-ultimate/idea-ultimate.iml +++ b/idea/idea-ultimate/idea-ultimate.iml @@ -5,7 +5,6 @@ - diff --git a/idea/idea-ultimate/resources/inspectionDescriptions/KotlinFinalClassOrFunSpring.html b/idea/idea-ultimate/resources/inspectionDescriptions/KotlinFinalClassOrFunSpring.html deleted file mode 100644 index 78265005eb0..00000000000 --- a/idea/idea-ultimate/resources/inspectionDescriptions/KotlinFinalClassOrFunSpring.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This inspection reports final Kotlin classes and functions annotated with Spring @Component, @Configuration or @Bean annotations - - diff --git a/idea/idea-ultimate/src/META-INF/kotlin-spring.xml b/idea/idea-ultimate/src/META-INF/kotlin-spring.xml index 8999970dab2..42836638cd3 100644 --- a/idea/idea-ultimate/src/META-INF/kotlin-spring.xml +++ b/idea/idea-ultimate/src/META-INF/kotlin-spring.xml @@ -1,11 +1,5 @@ - + \ No newline at end of file diff --git a/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/inspections/KotlinFinalClassOrFunSpringInspection.kt b/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/inspections/KotlinFinalClassOrFunSpringInspection.kt deleted file mode 100644 index e2778817373..00000000000 --- a/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/inspections/KotlinFinalClassOrFunSpringInspection.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.spring.inspections - -import com.intellij.codeInsight.highlighting.HighlightUsagesDescriptionLocation -import com.intellij.codeInspection.LocalQuickFix -import com.intellij.codeInspection.ProblemDescriptor -import com.intellij.codeInspection.ProblemHighlightType -import com.intellij.codeInspection.ProblemsHolder -import com.intellij.openapi.project.Project -import com.intellij.psi.ElementDescriptionUtil -import com.intellij.psi.PsiElementVisitor -import com.intellij.spring.constants.SpringAnnotationsConstants -import com.intellij.spring.model.jam.stereotype.SpringComponent -import com.intellij.spring.model.jam.stereotype.SpringConfiguration -import org.jetbrains.kotlin.asJava.toLightClass -import org.jetbrains.kotlin.asJava.toLightMethods -import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection -import org.jetbrains.kotlin.idea.spring.isAnnotatedWith -import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject -import org.jetbrains.kotlin.psi.psiUtil.isInheritable -import org.jetbrains.kotlin.psi.psiUtil.isOverridable - -class KotlinFinalClassOrFunSpringInspection : AbstractKotlinInspection() { - class QuickFix(private val element: T) : LocalQuickFix { - override fun getName(): String { - return "Make ${ElementDescriptionUtil.getElementDescription(element, HighlightUsagesDescriptionLocation.INSTANCE)} open" - } - - override fun getFamilyName() = "Make declaration open" - - override fun applyFix(project: Project, problemDescriptor: ProblemDescriptor) { - (element as? KtNamedDeclaration)?.containingClassOrObject?.addModifier(KtTokens.OPEN_KEYWORD) - element.addModifier(KtTokens.OPEN_KEYWORD) - } - } - - private fun getMessage(declaration: KtNamedDeclaration): String? { - when (declaration) { - is KtClass -> { - val lightClass = declaration.toLightClass() ?: return null - when { - SpringConfiguration.META.getJamElement(lightClass) != null -> return "@Configuration class should be declared open" - SpringComponent.META.getJamElement(lightClass) != null -> return "@Component class should be declared open" - } - } - - is KtNamedFunction -> { - val lightMethod = declaration.toLightMethods().firstOrNull() ?: return null - if (lightMethod.isAnnotatedWith(SpringAnnotationsConstants.JAVA_SPRING_BEAN)) return "@Bean function should be declared open" - } - } - return null - } - - override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { - return object: KtVisitorVoid() { - override fun visitNamedDeclaration(declaration: KtNamedDeclaration) { - when (declaration) { - is KtClass -> if (declaration.isInheritable()) return - is KtNamedFunction -> if (declaration.isOverridable()) return - else -> return - } - - val message = getMessage(declaration) ?: return - - holder.registerProblem( - declaration.nameIdentifier ?: declaration, - message, - ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - QuickFix(declaration) - ) - } - } - } -} \ No newline at end of file diff --git a/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/springUtils.kt b/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/springUtils.kt deleted file mode 100644 index 3596a30bdc6..00000000000 --- a/idea/idea-ultimate/src/org/jetbrains/kotlin/idea/spring/springUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.spring - -import com.intellij.codeInsight.AnnotationUtil -import com.intellij.openapi.module.ModuleUtilCore -import com.intellij.psi.PsiModifierListOwner -import com.intellij.spring.model.jam.utils.JamAnnotationTypeUtil - -internal fun PsiModifierListOwner.isAnnotatedWith(annotationFqName: String): Boolean { - val module = ModuleUtilCore.findModuleForPsiElement(this) ?: return false - return JamAnnotationTypeUtil.getInstance(module) - .getAnnotationTypesWithChildren(annotationFqName) - .mapNotNull { it.qualifiedName } - .any { AnnotationUtil.isAnnotated(this, it, true) } -} diff --git a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/codeInsight/UltimateInspectionTestGenerated.java b/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/codeInsight/UltimateInspectionTestGenerated.java deleted file mode 100644 index 0f3f21ecd0b..00000000000 --- a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/codeInsight/UltimateInspectionTestGenerated.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2010-2016 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.kotlin.idea.codeInsight; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -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/ultimateInspections") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class UltimateInspectionTestGenerated extends AbstractInspectionTest { - public void testAllFilesPresentInUltimateInspections() throws Exception { - KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/ultimateInspections"), Pattern.compile("^(inspections\\.test)$")); - } - - @TestMetadata("spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test") - public void testSpring_finalSpringAnnotatedDeclaration_inspectionData_Inspections_test() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test"); - doTest(fileName); - } -} diff --git a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/quickfix/UltimateQuickFixTestGenerated.java b/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/quickfix/UltimateQuickFixTestGenerated.java deleted file mode 100644 index bd81441132e..00000000000 --- a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/quickfix/UltimateQuickFixTestGenerated.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2010-2016 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.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.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/ultimateQuickFixes") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class UltimateQuickFixTestGenerated extends AbstractQuickFixTest { - public void testAllFilesPresentInUltimateQuickFixes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/ultimateQuickFixes"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); - } - - @TestMetadata("idea/testData/ultimateQuickFixes/spring") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Spring extends AbstractQuickFixTest { - public void testAllFilesPresentInSpring() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/ultimateQuickFixes/spring"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); - } - - @TestMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FinalSpringAnnotatedDeclaration extends AbstractQuickFixTest { - public void testAllFilesPresentInFinalSpringAnnotatedDeclaration() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); - } - - @TestMetadata("classWithComponentRuntime.kt") - public void testClassWithComponentRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("classWithConfigurationRuntime.kt") - public void testClassWithConfigurationRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("classWithCustomConfigurationRuntime.kt") - public void testClassWithCustomConfigurationRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("funWithBeanFinalClassRuntime.kt") - public void testFunWithBeanFinalClassRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("funWithBeanOpenClassRuntime.kt") - public void testFunWithBeanOpenClassRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("funWithCustomBeanFinalClassRuntime.kt") - public void testFunWithCustomBeanFinalClassRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt"); - doTest(fileName); - } - - @TestMetadata("funWithCustomBeanOpenClassRuntime.kt") - public void testFunWithCustomBeanOpenClassRuntime() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt"); - doTest(fileName); - } - } - } -} diff --git a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/SpringTestFixtureExtension.kt b/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/SpringTestFixtureExtension.kt index 97aed6f6d15..80e0db4799f 100644 --- a/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/SpringTestFixtureExtension.kt +++ b/idea/idea-ultimate/tests/org/jetbrains/kotlin/idea/spring/tests/SpringTestFixtureExtension.kt @@ -53,12 +53,9 @@ class SpringTestFixtureExtension() : TestFixtureExtension { override fun tearDown() { try { // clear existing SpringFacet configuration before running next test - module?.let { module -> - SpringFacet.getInstance(module)?.let { facet -> - facet.removeFileSets() - FacetUtil.deleteFacet(facet) - } - ConfigLibraryUtil.removeLibrary(module, "spring" + SpringFramework.FRAMEWORK_4_2_0.version) + module?.let { SpringFacet.getInstance(it) }?.let { + it.removeFileSets() + FacetUtil.deleteFacet(it) } } finally { diff --git a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/expected.xml b/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/expected.xml deleted file mode 100644 index b8aa7b0bd5b..00000000000 --- a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/expected.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - test.kt - 18 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Configuration class should be declared open - - - test.kt - 21 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Configuration class should be declared open - - - test.kt - 32 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Component class should be declared open - - - test.kt - 41 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - - test.kt - 44 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - - test.kt - 47 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - - test.kt - 50 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - - test.kt - 55 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - - test.kt - 58 - light_idea_test_case - - Final Kotlin class or function with Spring annotation - @Bean function should be declared open - - diff --git a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test b/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test deleted file mode 100644 index f9437be0350..00000000000 --- a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test +++ /dev/null @@ -1,2 +0,0 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.KotlinFinalClassOrFunSpringInspection -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension \ No newline at end of file diff --git a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/test.kt b/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/test.kt deleted file mode 100644 index c2d12b07e27..00000000000 --- a/idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/test.kt +++ /dev/null @@ -1,65 +0,0 @@ - -// WITH_RUNTIME - -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.Configuration -import org.springframework.stereotype.Component - -@Configuration -annotation class MyConfiguration - -@Bean -annotation class MyBean - -// @Configuration - -@Configuration -class Application1 - -@MyConfiguration -class Application2 - -@Configuration -open class Application3 - -@MyConfiguration -open class Application4 - -// @Component - -@Component -class Component1 - -@Component -open class Component2 - -// @Bean - -class Utils1 { - @Bean - fun foo1() = Component1() - - @MyBean - fun foo2() = Component2() - - @Bean - open fun foo3() = Component3() - - @MyBean - open fun foo4() = Component4() -} - -open class Utils2 { - @Bean - fun foo1() = Component1() - - @MyBean - fun foo2() = Component2() - - @Bean - open fun foo3() = Component3() - - @MyBean - open fun foo4() = Component4() -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/.inspection b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/.inspection deleted file mode 100644 index 4e681838d1b..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/.inspection +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.spring.inspections.KotlinFinalClassOrFunSpringInspection \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt deleted file mode 100644 index bd1f35511a7..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Make class Bean open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.stereotype.Component - -@Component -class Bean \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt.after deleted file mode 100644 index cd8c986adac..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithComponentRuntime.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Make class Bean open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.stereotype.Component - -@Component -open class Bean \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt deleted file mode 100644 index 2207fdfa6cb..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Make class Application open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Configuration - -@Configuration -class Application \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt.after deleted file mode 100644 index 57b7e3216f8..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithConfigurationRuntime.kt.after +++ /dev/null @@ -1,7 +0,0 @@ -// "Make class Application open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Configuration - -@Configuration -open class Application \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt deleted file mode 100644 index b162e021593..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt +++ /dev/null @@ -1,10 +0,0 @@ -// "Make class Application open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Configuration - -@Configuration -annotation class MyConfiguration - -@MyConfiguration -class Application \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt.after deleted file mode 100644 index 67167424348..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/classWithCustomConfigurationRuntime.kt.after +++ /dev/null @@ -1,10 +0,0 @@ -// "Make class Application open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Configuration - -@Configuration -annotation class MyConfiguration - -@MyConfiguration -open class Application \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt deleted file mode 100644 index 61ac1ddd46b..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt +++ /dev/null @@ -1,9 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -class Foo { - @Bean - fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt.after deleted file mode 100644 index 4dcbfeef188..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanFinalClassRuntime.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -open class Foo { - @Bean - open fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt deleted file mode 100644 index b5bd87e370b..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt +++ /dev/null @@ -1,9 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -open class Foo { - @Bean - fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt.after deleted file mode 100644 index 4dcbfeef188..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithBeanOpenClassRuntime.kt.after +++ /dev/null @@ -1,9 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -open class Foo { - @Bean - open fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt deleted file mode 100644 index 4f88a0b5a16..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt +++ /dev/null @@ -1,12 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -@Bean -annotation class MyBean - -class Foo { - @MyBean - fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt.after deleted file mode 100644 index 777c72f8120..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanFinalClassRuntime.kt.after +++ /dev/null @@ -1,12 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -@Bean -annotation class MyBean - -open class Foo { - @MyBean - open fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt deleted file mode 100644 index d12f89144e2..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt +++ /dev/null @@ -1,12 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -@Bean -annotation class MyBean - -open class Foo { - @MyBean - fun foo() = "" -} \ No newline at end of file diff --git a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt.after b/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt.after deleted file mode 100644 index 777c72f8120..00000000000 --- a/idea/testData/ultimateQuickFixes/spring/finalSpringAnnotatedDeclaration/funWithCustomBeanOpenClassRuntime.kt.after +++ /dev/null @@ -1,12 +0,0 @@ -// "Make function foo open" "true" -// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension -// DISABLE-ERRORS -import org.springframework.context.annotation.Bean - -@Bean -annotation class MyBean - -open class Foo { - @MyBean - open fun foo() = "" -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt index 8445928af99..e99d625c39e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt @@ -24,15 +24,21 @@ import com.intellij.codeInspection.ex.InspectionManagerEx import com.intellij.codeInspection.ex.LocalInspectionToolWrapper import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.util.io.FileUtil +import com.intellij.psi.PsiFile import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.InspectionTestUtil import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl -import org.jetbrains.kotlin.idea.test.* +import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil +import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File +import kotlin.test.assertFalse +import java.util.* abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() { companion object { @@ -58,8 +64,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() val inspectionClass = Class.forName(InTextDirectivesUtils.findStringWithPrefixes(options, "// INSPECTION_CLASS: ")!!) val toolWrapper = LocalInspectionToolWrapper(inspectionClass.newInstance() as LocalInspectionTool) - val fixtureClasses = InTextDirectivesUtils.findListWithPrefixes(options, "// FIXTURE_CLASS: ") - val inspectionsTestDir = optionsFile.parentFile!! val srcDir = inspectionsTestDir.parentFile!! @@ -70,7 +74,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() val psiFiles = srcDir.walkTopDown().onEnter { it.name != "inspectionData" }.mapNotNull { file -> if (file.isDirectory) { - null + null } else if (file.extension != "kt") { val filePath = file.relativeTo(srcDir).invariantSeparatorsPath @@ -108,8 +112,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() ) } - fixtureClasses.forEach { TestFixtureExtension.loadFixture(it, myFixture.module) } - val scope = AnalysisScope(project, psiFiles.map { it.virtualFile!! }) scope.invalidate() @@ -137,8 +139,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() } finally { - fixtureClasses.forEach { TestFixtureExtension.unloadFixture(it) } - if (isWithRuntime) { ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myFixture.module, IdeaTestUtil.getMockJdk17()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java index ccab3d7560c..25187c4b4d5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.java @@ -49,7 +49,6 @@ import org.jetbrains.kotlin.idea.quickfix.utils.QuickfixTestUtilsKt; import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil; import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils; import org.jetbrains.kotlin.idea.test.PluginTestCaseBase; -import org.jetbrains.kotlin.idea.test.TestFixtureExtension; import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.KotlinTestUtils; @@ -58,7 +57,6 @@ import org.junit.Assert; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -134,15 +132,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { public void run() { String fileText = ""; String expectedErrorMessage = ""; - List fixtureClasses = Collections.emptyList(); try { fileText = FileUtil.loadFile(testFile, CharsetToolkit.UTF8_CHARSET); - - fixtureClasses = InTextDirectivesUtils.findListWithPrefixes(fileText, "// FIXTURE_CLASS: "); - for (String fixtureClass : fixtureClasses) { - TestFixtureExtension.Companion.loadFixture(fixtureClass, getModule()); - } - expectedErrorMessage = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// SHOULD_FAIL_WITH: "); String contents = StringUtil.convertLineSeparators(fileText); quickFixTestCase.configureFromFileText(testFile.getName(), contents); @@ -166,9 +157,6 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase { fail(testName); } } finally { - for (String fixtureClass : fixtureClasses) { - TestFixtureExtension.Companion.unloadFixture(fixtureClass); - } ConfigLibraryUtil.unconfigureLibrariesByDirective(getModule(), fileText); } }