From 2b54f1ac7252b6da7d65d145de10b83be9b18d7c Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Fri, 6 Jan 2017 18:50:15 +0100 Subject: [PATCH] "Add names to call arguments" shouldn't appear when the only argument is a trailing lambda Fixes #KT-15501 --- .../idea/intentions/AddNamesToCallArgumentsIntention.kt | 9 +++------ .../intentions/addNamesToCallArguments/trailingLambda.kt | 6 ++++++ .../kotlin/idea/intentions/IntentionTestGenerated.java | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 idea/testData/intentions/addNamesToCallArguments/trailingLambda.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt index b009eaa367c..d63455a3feb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddNamesToCallArgumentsIntention.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 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. @@ -19,10 +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.KtCallElement -import org.jetbrains.kotlin.psi.KtLambdaArgument -import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.psi.KtValueArgument +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatchStatus @@ -35,7 +32,7 @@ class AddNamesToCallArgumentsIntention : SelfTargetingRangeIntention Unit) {} + +fun bar() { + foo {} +} \ 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 0a459087086..84e87bcbfe3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 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. @@ -473,6 +473,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("trailingLambda.kt") + public void testTrailingLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNamesToCallArguments/trailingLambda.kt"); + doTest(fileName); + } + @TestMetadata("varargMultiple.kt") public void testVarargMultiple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addNamesToCallArguments/varargMultiple.kt");