diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOverrideToEqualsHashCodeToStringFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOverrideToEqualsHashCodeToStringFix.kt deleted file mode 100644 index 599ec4c1d19..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOverrideToEqualsHashCodeToStringFix.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2010-2015 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.codeInsight.FileModificationService -import com.intellij.codeInsight.intention.IntentionAction -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.lexer.KtTokens.OVERRIDE_KEYWORD -import org.jetbrains.kotlin.lexer.KtTokens.PUBLIC_KEYWORD -import org.jetbrains.kotlin.psi.KtNamedFunction -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode - -object AddOverrideToEqualsHashCodeToStringActionFactory : KotlinSingleIntentionActionFactory() { - private val NAME = "Add 'override' to equals, hashCode, toString in project" - - private fun isEqualsHashCodeOrToString(element: KtNamedFunction): Boolean { - return when (element.name) { - "equals" -> { - val paramTypeRef = element.valueParameters.singleOrNull()?.typeReference ?: return false - val paramType = paramTypeRef.analyze(BodyResolveMode.PARTIAL)[BindingContext.TYPE, paramTypeRef] ?: return false - KotlinBuiltIns.isNullableAny(paramType) - } - - "hashCode", "toString" -> element.valueParameters.isEmpty() - - else -> false - } - } - - private fun KtNamedFunction.doInvoke() { - if (!FileModificationService.getInstance().preparePsiElementForWrite(this)) return - addModifier(OVERRIDE_KEYWORD) - removeModifier(PUBLIC_KEYWORD) - } - - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - return WholeProjectForEachElementOfTypeFix.createByPredicate( - predicate = { isEqualsHashCodeOrToString(it) }, - taskProcessor = { it.doInvoke() }, - name = NAME - ) - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 170ff403004..5d54788cf36 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -202,8 +202,6 @@ class QuickFixRegistrar : QuickFixContributor { VAL_OR_VAR_ON_CATCH_PARAMETER.registerFactory(RemoveValVarFromParameterFix) VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER.registerFactory(RemoveValVarFromParameterFix) - VIRTUAL_MEMBER_HIDDEN.registerFactory(AddOverrideToEqualsHashCodeToStringActionFactory) - UNUSED_VARIABLE.registerFactory(RemovePsiElementSimpleFix.RemoveVariableFactory) UNUSED_VARIABLE.registerFactory(RenameToUnderscoreFix.Factory) diff --git a/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt b/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt deleted file mode 100644 index 7b77b1d50b2..00000000000 --- a/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt +++ /dev/null @@ -1,29 +0,0 @@ -// "Add 'override' to equals, hashCode, toString in project" "true" - -class A { - fun equals(other: Any?) = false - fun hashCode() = 0 - fun toString(): String { - return "A" - } -} - -class B { - open fun equals(other: Any?) = false - open fun hashCode(): Int { - return 42 - } - open fun toString() = "" -} - -class C { - public fun equals(other: Any?): Boolean = true - public fun hashCode() = 0 - public fun toString() = "" -} - -class D { - public open fun equals(o: Any?) = false - public open fun hashCode(): Int = 239 - public open fun toString() = "" -} diff --git a/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt.after b/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt.after deleted file mode 100644 index 485c6315b39..00000000000 --- a/idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt.after +++ /dev/null @@ -1,29 +0,0 @@ -// "Add 'override' to equals, hashCode, toString in project" "true" - -class A { - override fun equals(other: Any?) = false - override fun hashCode() = 0 - override fun toString(): String { - return "A" - } -} - -class B { - override fun equals(other: Any?) = false - override fun hashCode(): Int { - return 42 - } - override fun toString() = "" -} - -class C { - override fun equals(other: Any?): Boolean = true - override fun hashCode() = 0 - override fun toString() = "" -} - -class D { - override fun equals(o: Any?) = false - override fun hashCode(): Int = 239 - override fun toString() = "" -} diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index aa190662344..723e0fc66ab 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -6109,12 +6109,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Migration extends AbstractQuickFixTest { - @TestMetadata("addOverrideToEqualsHashCodeToString.kt") - public void testAddOverrideToEqualsHashCodeToString() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/addOverrideToEqualsHashCodeToString.kt"); - doTest(fileName); - } - public void testAllFilesPresentInMigration() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); } diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java index b168f4dff2c..72aee4ed1f9 100644 --- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java +++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java @@ -4117,8 +4117,7 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo @TestMetadata("RedunduntTypeCastAndProhibitedInline.java") public void testRedunduntTypeCastAndProhibitedInline() throws Exception { - String fileName = KotlinTestUtils - .navigationMetadata("j2k/testData/fileOrElement/postProcessing/RedunduntTypeCastAndProhibitedInline.java"); + String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/postProcessing/RedunduntTypeCastAndProhibitedInline.java"); doTest(fileName); }