From 804e03379de139a52d8eb28c9eb6f36b846c428b Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Thu, 31 Jan 2019 22:50:28 +0900 Subject: [PATCH] Remove unused function parameter: do not propose for property setter parameter #KT-29606 Fixed --- .../idea/quickfix/RemoveUnusedFunctionParameterFix.kt | 5 ++++- .../removeUnusedParameterOfPropertySetter.kt | 7 +++++++ .../kotlin/idea/quickfix/QuickFixTestGenerated.java | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 idea/testData/quickfix/changeSignature/removeUnusedParameterOfPropertySetter.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUnusedFunctionParameterFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUnusedFunctionParameterFix.kt index 691e4a31e59..b2557f5a765 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUnusedFunctionParameterFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveUnusedFunctionParameterFix.kt @@ -70,7 +70,10 @@ class RemoveUnusedFunctionParameterFix(parameter: KtParameter) : KotlinQuickFixA override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { val parameter = Errors.UNUSED_PARAMETER.cast(diagnostic).psiElement val parameterOwner = parameter.parent.parent - if (parameterOwner is KtFunctionLiteral || (parameterOwner is KtNamedFunction && parameterOwner.name == null)) return null + if (parameterOwner is KtFunctionLiteral + || (parameterOwner is KtNamedFunction && parameterOwner.name == null) + || parameterOwner is KtPropertyAccessor + ) return null return RemoveUnusedFunctionParameterFix(parameter) } diff --git a/idea/testData/quickfix/changeSignature/removeUnusedParameterOfPropertySetter.kt b/idea/testData/quickfix/changeSignature/removeUnusedParameterOfPropertySetter.kt new file mode 100644 index 00000000000..078d25ef04e --- /dev/null +++ b/idea/testData/quickfix/changeSignature/removeUnusedParameterOfPropertySetter.kt @@ -0,0 +1,7 @@ +// "Remove parameter 'value'" "false" +// ACTION: Specify type explicitly +class Abacaba { + var foo: String + get() = "" + set(value) {} +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 1f54188ee6d..fb9e93371ba 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -1909,6 +1909,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("idea/testData/quickfix/changeSignature/removeUnusedParameter.kt"); } + @TestMetadata("removeUnusedParameterOfPropertySetter.kt") + public void testRemoveUnusedParameterOfPropertySetter() throws Exception { + runTest("idea/testData/quickfix/changeSignature/removeUnusedParameterOfPropertySetter.kt"); + } + @TestMetadata("removeUnusedParameterWithTypeParameter.kt") public void testRemoveUnusedParameterWithTypeParameter() throws Exception { runTest("idea/testData/quickfix/changeSignature/removeUnusedParameterWithTypeParameter.kt");