diff options
author | Dmitry Gridin <dmitry.gridin@jetbrains.com> | 2021-01-26 20:16:45 +0700 |
---|---|---|
committer | kotlin-ide-monorepo-bot <kotlin-ide-monorepo-bot-no-reply@jetbrains.com> | 2021-01-26 14:50:14 +0000 |
commit | ff10ed22dd4ca28df2835529893c323efc3bd4b5 (patch) | |
tree | 098c735ffd76e7e4b46e351dfd6b8920eb5699da | |
parent | 41240ad43b04fa69847e1a3ed1b85705cb674372 (diff) | |
download | intellij-kotlin-ff10ed22dd4ca28df2835529893c323efc3bd4b5.tar.gz |
LambdaToAnonymousFunctionIntention: cleanup code
^KTIJ-1037
GitOrigin-RevId: 51bf04ab82baf8932e0ddee56fd562eae33dd0e5
-rw-r--r-- | idea/src/org/jetbrains/kotlin/idea/intentions/LambdaToAnonymousFunctionIntention.kt | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/LambdaToAnonymousFunctionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/LambdaToAnonymousFunctionIntention.kt index 753eb72d1e7d..3ec4898a08eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/LambdaToAnonymousFunctionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/LambdaToAnonymousFunctionIntention.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -48,8 +48,11 @@ class LambdaToAnonymousFunctionIntention : SelfTargetingIntention<KtLambdaExpres val context = element.analyze(BodyResolveMode.PARTIAL) if (call?.getResolvedCall(context)?.getParameterForArgument(argument)?.type?.isSuspendFunctionType == true) return false - val descriptor = - context[BindingContext.DECLARATION_TO_DESCRIPTOR, element.functionLiteral] as? AnonymousFunctionDescriptor ?: return false + val descriptor = context[ + BindingContext.DECLARATION_TO_DESCRIPTOR, + element.functionLiteral, + ] as? AnonymousFunctionDescriptor ?: return false + if (descriptor.valueParameters.any { it.name.isSpecial || it.type is ErrorType }) return false val lastElement = element.functionLiteral.arrow ?: element.functionLiteral.lBrace @@ -73,7 +76,9 @@ class LambdaToAnonymousFunctionIntention : SelfTargetingIntention<KtLambdaExpres lambda: KtLambdaExpression, functionDescriptor: FunctionDescriptor, functionName: String = "", - functionParameterName: (ValueParameterDescriptor, Int) -> String = { parameter, _ -> parameter.name.asString().quoteIfNeeded() }, + functionParameterName: (ValueParameterDescriptor, Int) -> String = { parameter, _ -> + parameter.name.asString().quoteIfNeeded() + }, typeParameters: Map<String, KtTypeReference> = emptyMap(), replaceElement: (KtNamedFunction) -> KtExpression = { lambda.replaced(it) } ): KtExpression? { |