diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt index 4e689a17ac1..15a59d59356 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNameToArgumentIntention.kt @@ -63,7 +63,7 @@ class AddNameToArgumentIntention val argumentList = argument.parent as? KtValueArgumentList ?: return null if (argument != argumentList.arguments.last { !it.isNamed() }) return null - val callExpr = argumentList.parent as? KtExpression ?: return null + val callExpr = argumentList.parent as? KtCallElement ?: return null val resolvedCall = callExpr.getResolvedCall(callExpr.analyze(BodyResolveMode.PARTIAL)) ?: return null val argumentMatch = resolvedCall.getArgumentMapping(argument) as? ArgumentMatch ?: return null if (argumentMatch.status != ArgumentMatchStatus.SUCCESS) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt index 15a701fbc6e..81d2b93062a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveArgumentNameIntention.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtCallElement import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.KtValueArgument import org.jetbrains.kotlin.psi.KtValueArgumentList @@ -38,7 +38,7 @@ class RemoveArgumentNameIntention val arguments = argumentList.arguments if (arguments.takeWhile { it != element }.any { it.isNamed() }) return null - val callExpr = argumentList.parent as? KtExpression ?: return null + val callExpr = argumentList.parent as? KtCallElement ?: return null val resolvedCall = callExpr.getResolvedCall(callExpr.analyze(BodyResolveMode.PARTIAL)) ?: return null val argumentMatch = resolvedCall.getArgumentMapping(element) as? ArgumentMatch ?: return null if (argumentMatch.valueParameter.index != arguments.indexOf(element)) return null diff --git a/idea/testData/intentions/addNameToArgument/superClassConstructor.kt b/idea/testData/intentions/addNameToArgument/superClassConstructor.kt new file mode 100644 index 00000000000..de337ceab10 --- /dev/null +++ b/idea/testData/intentions/addNameToArgument/superClassConstructor.kt @@ -0,0 +1,3 @@ +open class C(p1: Int, p2: Int) + +class D : C(1, 2) \ No newline at end of file diff --git a/idea/testData/intentions/addNameToArgument/superClassConstructor.kt.after b/idea/testData/intentions/addNameToArgument/superClassConstructor.kt.after new file mode 100644 index 00000000000..9bfbdbacc15 --- /dev/null +++ b/idea/testData/intentions/addNameToArgument/superClassConstructor.kt.after @@ -0,0 +1,3 @@ +open class C(p1: Int, p2: Int) + +class D : C(1, p2 = 2) \ No newline at end of file diff --git a/idea/testData/intentions/removeArgumentName/superClassConstructor.kt b/idea/testData/intentions/removeArgumentName/superClassConstructor.kt new file mode 100644 index 00000000000..501a19c48ab --- /dev/null +++ b/idea/testData/intentions/removeArgumentName/superClassConstructor.kt @@ -0,0 +1,3 @@ +open class C(p1: Int, p2: Int) + +class D : C(1, p2 = 2) \ No newline at end of file diff --git a/idea/testData/intentions/removeArgumentName/superClassConstructor.kt.after b/idea/testData/intentions/removeArgumentName/superClassConstructor.kt.after new file mode 100644 index 00000000000..de337ceab10 --- /dev/null +++ b/idea/testData/intentions/removeArgumentName/superClassConstructor.kt.after @@ -0,0 +1,3 @@ +open class C(p1: Int, p2: Int) + +class D : C(1, 2) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 11467eea4c4..4ca24dfb6e6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -292,6 +292,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("superClassConstructor.kt") + public void testSuperClassConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/superClassConstructor.kt"); + doTest(fileName); + } + @TestMetadata("vararg1.kt") public void testVararg1() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNameToArgument/vararg1.kt"); @@ -6973,6 +6979,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeArgumentName/star.kt"); doTest(fileName); } + + @TestMetadata("superClassConstructor.kt") + public void testSuperClassConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeArgumentName/superClassConstructor.kt"); + doTest(fileName); + } } @TestMetadata("idea/testData/intentions/removeBraces")